fix potential segfault in get_ioscheduler().
authorPhil <n0-1@users.sourceforge.net>
Sat, 29 Mar 2008 02:19:36 +0000 (02:19 +0000)
committerPhil <n0-1@users.sourceforge.net>
Sat, 29 Mar 2008 02:19:36 +0000 (02:19 +0000)
returning a const char * instead of a char * will lead to
trouble if the string is then tried to be free()'d.

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@1056 7f574dfc-610e-0410-a909-a81674777703

ChangeLog
src/linux.c

index 9db235e..cb933d7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
 
 2008-03-29
        * Increased C99 compliance.
+       * Fixed potential segfault in get_ioscheduler().
 
 2008-03-28
        * Fixed messed up percentages (fs_free_perc, fs_used_perc, mpd_percent,
index 2ac317f..e850983 100644 (file)
@@ -192,7 +192,7 @@ char *get_ioscheduler(char *disk)
        char buf[128];
 
        if (!disk)
-               return "n/a";
+               return strdup("n/a");
 
        snprintf(buf, 127, "/sys/block/%s/queue/scheduler", disk);
        if ((fp = fopen(buf, "r")) == NULL) {