fix possible mem leak in prepare_diskio_stat, fix return value on failure
authorBrenden Matthews <brenden1@rty.ca>
Mon, 31 Mar 2008 03:56:03 +0000 (03:56 +0000)
committerBrenden Matthews <brenden1@rty.ca>
Mon, 31 Mar 2008 03:56:03 +0000 (03:56 +0000)
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@1088 7f574dfc-610e-0410-a909-a81674777703

ChangeLog
src/diskio.c

index adb569c..c6f43a5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
 
 2008-03-30
        * Added mem_res and mem_vsize to $top.
+       * Improved parsing of diskio args
 
 2008-03-29
        * Increased C99 compliance.
index 0342818..dbd8164 100644 (file)
@@ -69,6 +69,10 @@ struct diskio_stat *prepare_diskio_stat(const char *s)
                ERR("too many diskio stats");
                return 0;
        }
+       if (new->dev) {
+               free(new->dev);
+               new->dev = 0;
+       }
        if (strncmp(s, "/dev/", 5) == 0) {
                // supplied a /dev/device arg, so cut off the /dev part
                new->dev = strndup(s + 5, text_buffer_size);
@@ -98,6 +102,7 @@ struct diskio_stat *prepare_diskio_stat(const char *s)
        fp = 0;
        if (!found) {
                ERR("diskio device '%s' does not exist", s);
+               return 0;
        }
        new->current = 0;
        new->current_read = 0;