This patch fixes two memory leaks if multiple probe names or probe ranges are
specified.
---
 parsers.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/parsers.c b/parsers.c
index 206e1d6..e940417 100644
--- a/parsers.c
+++ b/parsers.c
@@ -73,25 +73,25 @@ GSList *parse_probestring(struct sr_dev_inst *sdi, const 
char *probestring)
                                /* Need exactly two arguments. */
                                g_critical("Invalid probe syntax '%s'.", 
tokens[i]);
                                ret = SR_ERR;
-                               break;
+                               goto range_fail;
                        }
 
                        b = strtol(range[0], &eptr, 10);
                        if (eptr == range[0] || *eptr != '\0') {
                                g_critical("Invalid probe '%s'.", range[0]);
                                ret = SR_ERR;
-                               break;
+                               goto range_fail;
                        }
                        e = strtol(range[1], NULL, 10);
                        if (eptr == range[1] || *eptr != '\0') {
                                g_critical("Invalid probe '%s'.", range[1]);
                                ret = SR_ERR;
-                               break;
+                               goto range_fail;
                        }
                        if (b < 0 || b >= e) {
                                g_critical("Invalid probe range '%s'.", 
tokens[i]);
                                ret = SR_ERR;
-                               break;
+                               goto range_fail;
                        }
 
                        while (b <= e) {
@@ -110,6 +110,10 @@ GSList *parse_probestring(struct sr_dev_inst *sdi, const 
char *probestring)
                                probelist = g_slist_append(probelist, probe);
                                b++;
                        }
+range_fail:
+                       if (range)
+                               g_strfreev(range);
+
                        if (ret != SR_OK)
                                break;
                } else {
@@ -133,13 +137,11 @@ GSList *parse_probestring(struct sr_dev_inst *sdi, const 
char *probestring)
                                probe->name = g_strdup(names[1]);
                        }
                        probelist = g_slist_append(probelist, probe);
+
+                       if (names)
+                               g_strfreev(names);
                }
        }
-       if (range)
-               g_strfreev(range);
-
-       if (names)
-               g_strfreev(names);
 
        if (ret != SR_OK) {
                g_slist_free(probelist);
-- 
1.8.4.2


------------------------------------------------------------------------------
DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
Free app hosting. Or install the open source package on any LAMP server.
Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
_______________________________________________
sigrok-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sigrok-devel

Reply via email to