sigrok-cli: Fix memory leak if we save the default output format to a file.
authorpoljar (Damir Jelić) <poljar@poljar.org>
Tue, 19 Nov 2013 10:28:09 +0000 (11:28 +0100)
committerBert Vermeulen <bert@biot.com>
Tue, 19 Nov 2013 10:40:36 +0000 (11:40 +0100)
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.

session.c

index 82fea5574eaf0db878a7aed30bbdc2384f86abb5..12033dcc8316a9b8f362d3c751ea3745b883f513 100644 (file)
--- 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);
                }
        }