From: Stratos Psomadakis Date: Mon, 27 Jan 2014 10:30:15 +0000 (+0200) Subject: monitor: Cleanup mon->outbuf on write error X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~386^2~42^2~217^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=056f49ff2cf645dc484956b00b65a3aa18a1a9a3;p=sdk%2Femulator%2Fqemu.git monitor: Cleanup mon->outbuf on write error In case monitor_flush() fails to write the contents of mon->outbuf to the output device, mon->outbuf is not cleaned up properly. Check the return code of the qemu_chr_fe_write() function and cleanup the outbuf if it fails. References: http://lists.nongnu.org/archive/html/qemu-devel/2014-01/msg02890.html Signed-off-by: Stratos Psomadakis Signed-off-by: Dimitris Aragiorgis Signed-off-by: Luiz Capitulino --- diff --git a/monitor.c b/monitor.c index 80456fbe5b..cba56bc4b7 100644 --- a/monitor.c +++ b/monitor.c @@ -288,8 +288,8 @@ void monitor_flush(Monitor *mon) if (len && !mon->mux_out) { rc = qemu_chr_fe_write(mon->chr, (const uint8_t *) buf, len); - if (rc == len) { - /* all flushed */ + if ((rc < 0 && errno != EAGAIN) || (rc == len)) { + /* all flushed or error */ QDECREF(mon->outbuf); mon->outbuf = qstring_new(); return;