Sophie

Sophie

distrib > Fedora > 13 > i386 > media > updates-src > by-pkgid > d3da47e473396ce88b22c4103ac14adc > files > 9

iftop-0.17-12.fc13.src.rpm

Backported patch from Mats Erik Andersson <mats.andersson@gisladisker.se>
for iftop >= 0.17, which fixes a segfault when using the same command line
argument multiple times. For further information, please have a look to
Debian bug ID #425488.

--- iftop-0.17/cfgfile.c		2010-11-18 23:18:15.237057004 +0100
+++ iftop-0.17/cfgfile.c.stringmap	2010-11-18 23:22:57.360812876 +0100
@@ -230,8 +230,15 @@
     stringmap S;
 
     S = stringmap_find(config, directive);
-    if (S) stringmap_delete_free(S);
-    stringmap_insert(config, directive, item_ptr(xstrdup(s)));
+    if (S) {
+        /* Replace any already stored string value.
+        * The node can simply not be deleted straight off,
+        * due to possible presence of leafs on either side. */
+        if (S->d.v)
+            xfree(S->d.v);
+        S->d.v = xstrdup(s);
+    } else
+        stringmap_insert(config, directive, item_ptr(xstrdup(s)));
 }
 
 int read_config(char *file, int whinge_on_error) {
--- iftop-0.17/stringmap.c		2010-11-18 23:18:15.229995287 +0100
+++ iftop-0.17/stringmap.c.stringmap	2010-11-18 23:24:20.853809501 +0100
@@ -61,11 +61,11 @@
 }
 
 /* stringmap_insert:
- * Insert into S an item having key k and value d. Returns an existing key
- * or NULL if it was inserted. 
+ * Insert into S an item having key k and value d. Returns a pointer to
+ * the existing item value, or NULL if a new item was created. 
  */
 item *stringmap_insert(stringmap S, const char *k, const item d) {
-    if (!S) return 0;
+    if (!S) return NULL;
     if (S->key == NULL) {
         S->key = xstrdup(k);
         S->d   = d;