]> git.webhop.me Git - lcd4linux.git/commitdiff
fixed memory leak in using strdup() instead of strdupa()
authorvolker <volker@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Sun, 17 Jan 2010 12:25:17 +0000 (12:25 +0000)
committervolker <volker@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Sun, 17 Jan 2010 12:25:17 +0000 (12:25 +0000)
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@1080 3ae390bd-cb1e-0410-b409-cd5a39f66f1f

plugin_i2c_sensors.c

index 71cbe3e5668c3407c558e882c36e87dae3800b08..6092cbfda9a3196846c16962f757c9280020f84b 100644 (file)
@@ -188,7 +188,12 @@ static int parse_i2c_sensors_procfs(const char *key)
        return -1;
     }
 
+#ifndef __MAX_OS_X_VERSION_10_3
+    running = strndup(buffer, sizeof(buffer));
+#else
+    // there is no strndup in OSX
     running = strdup(buffer);
+#endif
     while (1) {
        value = strsep(&running, delim);
        /* debug("%s pos %i -> %s", file, pos , value); */
@@ -202,6 +207,7 @@ static int parse_i2c_sensors_procfs(const char *key)
            pos++;
        }
     }
+    free(running);
     return 0;
 }