]> sigrok.org Git - libsigrok.git/blobdiff - src/input/csv.c
input: fix leak of config data in several input modules
[libsigrok.git] / src / input / csv.c
index 0a2d7276d996eb14b5f0310999feb1ed2e3c8c06..ed2b49409b43d9b25c611ce47090c435d90cb5a2 100644 (file)
@@ -17,6 +17,7 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <config.h>
 #include <stdlib.h>
 #include <string.h>
 #include <glib.h>
@@ -132,17 +133,6 @@ struct context {
        size_t line_number;
 };
 
-static int format_match(GHashTable *metadata)
-{
-       char *buf;
-
-       buf = g_hash_table_lookup(metadata, GINT_TO_POINTER(SR_INPUT_META_MIMETYPE));
-       if (!strcmp(buf, "text/csv"))
-               return SR_OK;
-
-       return SR_ERR;
-}
-
 static void strip_comment(char *buf, const GString *prefix)
 {
        char *ptr;
@@ -631,6 +621,7 @@ static int process_buffer(struct sr_input *in)
                        src = sr_config_new(SR_CONF_SAMPLERATE, g_variant_new_uint64(samplerate));
                        meta.config = g_slist_append(NULL, src);
                        sr_session_send(in->sdi, &packet);
+                       g_slist_free(meta.config);
                        sr_config_free(src);
                }
 
@@ -794,7 +785,7 @@ static struct sr_option options[] = {
        ALL_ZERO
 };
 
-static struct sr_option *get_options(void)
+static const struct sr_option *get_options(void)
 {
        if (!options[0].def) {
                options[0].def = g_variant_ref_sink(g_variant_new_int32(0));
@@ -816,9 +807,7 @@ SR_PRIV struct sr_input_module input_csv = {
        .name = "CSV",
        .desc = "Comma-separated values",
        .exts = (const char*[]){"csv", NULL},
-       .metadata = { SR_INPUT_META_MIMETYPE },
        .options = get_options,
-       .format_match = format_match,
        .init = init,
        .receive = receive,
        .end = end,