From: poljar (Damir Jelić) Date: Tue, 19 Nov 2013 10:28:09 +0000 (+0100) Subject: sigrok-cli: Fix memory leak if we save the default output format to a file. X-Git-Tag: sigrok-cli-0.5.0~60 X-Git-Url: https://sigrok.org/gitweb/?p=sigrok-cli.git;a=commitdiff_plain;h=30364883abef6a52180fc6244d79788298729137 sigrok-cli: Fix memory leak if we save the default output format to a file. g_free_byte_array accepts as the second argument a gboolean which determines if the actual byte data should also be freed: https://developer.gnome.org/glib/2.28/glib-Byte-Arrays.html#g-byte-array-free If we pass a FALSE here the data should be freed with g_free(), instead just pass TRUE and the data will be automatically freed. --- diff --git a/session.c b/session.c index 82fea55..12033dc 100644 --- a/session.c +++ b/session.c @@ -440,7 +440,7 @@ void datafeed_in(const struct sr_dev_inst *sdi, if (sr_session_save(opt_output_file, sdi, savebuf->data, unitsize, savebuf->len / unitsize) != SR_OK) g_critical("Failed to save session."); - g_byte_array_free(savebuf, FALSE); + g_byte_array_free(savebuf, TRUE); } }