[FIX] skip line function 84/45584/6
authorVitaliy Cherepanov <v.cherepanov@samsung.com>
Fri, 7 Aug 2015 13:34:17 +0000 (16:34 +0300)
committerVitaliy Andreevich <v.cherepanov@samsung.com>
Wed, 12 Aug 2015 11:16:15 +0000 (04:16 -0700)
fix possible fail on reading proc files

Change-Id: I883cc7a1902c54360fdc912e64d5f8d13bc7e54e
Signed-off-by: Vitaliy Cherepanov <v.cherepanov@samsung.com>
daemon/sys_stat.c

index 2abe299..52083a2 100644 (file)
@@ -1505,10 +1505,11 @@ static void skip_lines(FILE * fp, unsigned int count)
        size_t buflen;
        unsigned int index;
        for (index = 0; index != count; ++index) {
+               buffer = NULL;
                if (getline(&buffer, &buflen, fp) < 0)
                        LOGE("file scan fail\n");
+               free(buffer);
        }
-       free(buffer);
 }
 
 static int skip_tokens(FILE * fp, unsigned int count)