diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2010-07-14 16:08:55 +0000 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2010-07-14 16:08:55 +0000 |
commit | a3c2b432b50c49305c60e42f5b9f1759ef3c1368 (patch) | |
tree | 44c5ed29f91135d157c893e3c08c21a6a7ead00f /render/directory.c | |
parent | cfdae54bc3ac6fd35675171ba2ebaf3d8b029af5 (diff) | |
download | netsurf-a3c2b432b50c49305c60e42f5b9f1759ef3c1368.tar.gz netsurf-a3c2b432b50c49305c60e42f5b9f1759ef3c1368.tar.bz2 |
Squash mimetype may be used uninitialised warning.
svn path=/trunk/netsurf/; revision=10638
Diffstat (limited to 'render/directory.c')
-rw-r--r-- | render/directory.c | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/render/directory.c b/render/directory.c index 04f5991c7..6ff149713 100644 --- a/render/directory.c +++ b/render/directory.c @@ -143,7 +143,8 @@ bool directory_convert(struct content *c) { bool compare; char *up; struct stat filestat; - char *filepath, *mimetype; + char *filepath, *mimetype = NULL; + int filepath_size; char moddate[100]; char modtime[100]; bool extendedinfo, evenrow = false; @@ -235,21 +236,25 @@ bool directory_convert(struct content *c) { /* Skip . and .. entries */ continue; - extendedinfo = false; - - filepath = malloc(strlen(path) + strlen(entry->d_name) + 2); + filepath_size = strlen(path) + strlen(entry->d_name) + 2; + filepath = malloc(filepath_size); if (filepath != NULL) { strcpy(filepath, path); - if (path_add_part(filepath, - (strlen(path) + - strlen(entry->d_name) + 2), - entry->d_name)) { - if (stat(filepath, &filestat) == 0) { - mimetype = fetch_mimetype(filepath); - extendedinfo = true; - } + if (path_add_part(filepath, filepath_size, + entry->d_name) == false) { + msg_data.error = messages_get("MiscErr"); + content_broadcast(c, CONTENT_MSG_ERROR, + msg_data); + return false; } - free(filepath); + if (stat(filepath, &filestat) == 0) + extendedinfo = true; + else + extendedinfo = false; + } else { + msg_data.error = messages_get("MiscErr"); + content_broadcast(c, CONTENT_MSG_ERROR, msg_data); + return false; } /* Start row and print item name */ @@ -288,6 +293,7 @@ bool directory_convert(struct content *c) { moddate, modtime); } else { /* File: Print type, size, and date/time */ + mimetype = fetch_mimetype(filepath); snprintf(buffer, sizeof(buffer), "<span class=\"type\">%s</span> " "<span class=\"size\">%d</span>" @@ -319,8 +325,11 @@ bool directory_convert(struct content *c) { else evenrow = false; - if (mimetype) + if (mimetype != NULL) { free(mimetype); + mimetype = NULL; + } + free(filepath); } closedir(parent); |