Prevent use of uninitialized variable in examples 78/69478/1
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Fri, 13 May 2016 10:31:01 +0000 (12:31 +0200)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Fri, 13 May 2016 10:32:03 +0000 (12:32 +0200)
Change-Id: I79052b160cd3d009fe89652a33e0450ee1e516d3

examples/misc.c

index b3a8fdced21922234114c9983af601c881220678..ef8c53cdfc690119bbde6dcb139a19d0e6e99214 100644 (file)
@@ -54,7 +54,7 @@ int read_file(const char *path, char **data, size_t *data_len)
        int ret;
        char tmp[BUF_SIZE];
        char *buf = NULL;
-       size_t buf_len;
+       size_t buf_len = 0;
        FILE *f;
 
        f = fopen(path, "r");
@@ -71,7 +71,6 @@ int read_file(const char *path, char **data, size_t *data_len)
                                        ret = -1;
                                        break;
                                }
-                               buf_len = 0;
                        } else {
                                char *new_buf = yaca_realloc(buf, buf_len + read);
                                if (new_buf == NULL) {