libextractor

GNU libextractor
Log | Files | Refs | Submodules | README | LICENSE

commit 8fcb8953c9a414e1e81c566c6dd9219014b418e2
parent b564426ffd894b839684662d85b62fe2c6c497ff
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sat, 12 Jun 2010 20:33:10 +0000

bugfixes

Diffstat:
MChangeLog | 4++++
Msrc/common/convert.c | 7+++++++
Msrc/main/extract.c | 24+++++++++++++++---------
Msrc/main/extractor.c | 150++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------
Msrc/main/extractor_print.c | 19+++++++++++++------
Msrc/main/iconv.c | 2++
Msrc/plugins/gif_extractor.c | 43++++++++++++++++++++++++-------------------
Msrc/plugins/html_extractor.c | 30+++++++++++++++++++-----------
Msrc/plugins/id3v23_extractor.c | 14+++++++++-----
Msrc/plugins/id3v24_extractor.c | 14+++++++++-----
Msrc/plugins/id3v2_extractor.c | 3++-
Msrc/plugins/ole2_extractor.c | 44+++++++++++++++++++++++++++++---------------
Msrc/plugins/pdf_extractor.cc | 19++++++++++++++-----
Msrc/plugins/ps_extractor.c | 6++++--
Msrc/plugins/zip_extractor.c | 61+++++++++++++++++++++++++++++++++++--------------------------
15 files changed, 296 insertions(+), 144 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,7 @@ +Sat Jun 12 22:32:32 CEST 2010 + Fixing various bugs, including some that can cause crashes given + malformed inputs. -CG + Sat Jun 12 16:23:14 CEST 2010 Only pass 'unsigned char's to 'isspace' and similar functions. -CG diff --git a/src/common/convert.c b/src/common/convert.c @@ -47,6 +47,8 @@ EXTRACTOR_common_convert_to_utf8 (const char *input, size_t len, const char *cha return strdup (i); tmpSize = 3 * len + 4; tmp = malloc (tmpSize); + if (tmp == NULL) + return NULL; itmp = tmp; finSize = tmpSize; if (iconv (cd, (char **) &input, &len, &itmp, &finSize) == (size_t) - 1) @@ -56,6 +58,11 @@ EXTRACTOR_common_convert_to_utf8 (const char *input, size_t len, const char *cha return strdup (i); } ret = malloc (tmpSize - finSize + 1); + if (ret == NULL) + { + free (tmp); + return NULL; + } memcpy (ret, tmp, tmpSize - finSize); ret[tmpSize - finSize] = '\0'; free (tmp); diff --git a/src/main/extract.c b/src/main/extract.c @@ -253,11 +253,14 @@ print_selected_keywords (void *cls, data); else keyword = strdup(data); - fprintf (stdout, - "%s - %s\n", - stype, - keyword); - free(keyword); + if (keyword != NULL) + { + fprintf (stdout, + "%s - %s\n", + stype, + keyword); + free(keyword); + } if (cd != (iconv_t) -1) iconv_close(cd); break; @@ -327,10 +330,13 @@ print_selected_keywords_grep_friendly (void *cls, data); else keyword = strdup(data); - fprintf (stdout, - "'%s' ", - keyword); - free(keyword); + if (keyword != NULL) + { + fprintf (stdout, + "'%s' ", + keyword); + free(keyword); + } if (cd != (iconv_t) -1) iconv_close(cd); break; diff --git a/src/main/extractor.c b/src/main/extractor.c @@ -175,6 +175,7 @@ get_path_from_proc_exe() { char line[1024]; char dir[1024]; char * lnk; + char * ret; char * lestr; size_t size; FILE * f; @@ -222,11 +223,14 @@ get_path_from_proc_exe() { } lnk[size] = '\0'; lnk = cut_bin(lnk); - lnk = realloc(lnk, strlen(lnk) + 5); - if (lnk == NULL) - return NULL; - strcat(lnk, "lib/"); /* guess "lib/" as the library dir */ - return lnk; + ret = realloc(lnk, strlen(lnk) + 5); + if (ret == NULL) + { + free (lnk); + return NULL; + } + strcat(ret, "lib/"); /* guess "lib/" as the library dir */ + return ret; } #endif @@ -234,11 +238,15 @@ get_path_from_proc_exe() { /** * Try to determine path with win32-specific function */ -static char * get_path_from_module_filename() { +static char * +get_path_from_module_filename() { char * path; + char * ret; char * idx; path = malloc(4103); /* 4096+nil+6 for "/lib/" catenation */ + if (path == NULL) + return NULL; GetModuleFileName(NULL, path, 4096); idx = path + strlen(path); while ( (idx > path) && @@ -247,9 +255,14 @@ static char * get_path_from_module_filename() { idx--; *idx = '\0'; path = cut_bin(path); - path = realloc(path, strlen(path) + 6); - strcat(path, "/lib/"); /* guess "lib/" as the library dir */ - return path; + ret = realloc(path, strlen(path) + 6); + if (ret == NULL) + { + free (path); + return NULL; + } + strcat(ret, "/lib/"); /* guess "lib/" as the library dir */ + return ret; } #endif @@ -293,6 +306,7 @@ get_path_from_PATH() { char * pos; char * end; char * buf; + char * ret; const char * p; size_t size; @@ -321,11 +335,14 @@ get_path_from_PATH() { if (pos == NULL) return NULL; pos = cut_bin(pos); - pos = realloc(pos, strlen(pos) + 5); - if (pos == NULL) - return NULL; - strcat(pos, "lib/"); - return pos; + ret = realloc(pos, strlen(pos) + 5); + if (ret == NULL) + { + free (pos); + return NULL; + } + strcat(ret, "lib/"); + return ret; } pos = end + 1; } @@ -337,11 +354,14 @@ get_path_from_PATH() { if (pos == NULL) return NULL; pos = cut_bin(pos); - pos = realloc(pos, strlen(pos) + 5); - if (pos == NULL) - return NULL; - strcat(pos, "lib/"); - return pos; + ret = realloc(pos, strlen(pos) + 5); + if (ret == NULL) + { + free (pos); + return NULL; + } + strcat(ret, "lib/"); + return ret; } free(buf); free(path); @@ -1157,6 +1177,12 @@ process_requests (struct EXTRACTOR_PluginList *plugin, HANDLE map; #endif + if (plugin == NULL) + { + close (in); + close (out); + return; + } if (0 != plugin_load (plugin)) { close (in); @@ -1269,11 +1295,9 @@ write_plugin_data (int fd, const struct EXTRACTOR_PluginList *plugin) i = strlen (plugin->libname) + 1; write (fd, &i, sizeof (size_t)); write (fd, plugin->libname, i); - i = strlen (plugin->short_libname) + 1; write (fd, &i, sizeof (size_t)); write (fd, plugin->short_libname, i); - if (plugin->plugin_options != NULL) { i = strlen (plugin->plugin_options) + 1; @@ -1281,11 +1305,11 @@ write_plugin_data (int fd, const struct EXTRACTOR_PluginList *plugin) } else { - i = 1; - str = ""; + i = 0; } write (fd, &i, sizeof (size_t)); - write (fd, str, i); + if (i > 0) + write (fd, str, i); } static struct EXTRACTOR_PluginList * @@ -1295,34 +1319,62 @@ read_plugin_data (int fd) size_t i; ret = malloc (sizeof (struct EXTRACTOR_PluginList)); - + if (ret == NULL) + return NULL; read (fd, &i, sizeof (size_t)); ret->libname = malloc (i); + if (ret->libname == NULL) + { + free (ret); + return NULL; + } read (fd, ret->libname, i); read (fd, &i, sizeof (size_t)); ret->short_libname = malloc (i); + if (ret->short_libname == NULL) + { + free (ret->libname); + free (ret); + return NULL; + } read (fd, ret->short_libname, i); read (fd, &i, sizeof (size_t)); - ret->plugin_options = malloc (i); - read (fd, ret->plugin_options, i); - + if (i == 0) + { + ret->plugin_options = NULL; + } + else + { + ret->plugin_options = malloc (i); + if (ret->plugin_options == NULL) + { + free (ret->short_libname); + free (ret->libname); + free (ret); + return NULL; + } + read (fd, ret->plugin_options, i); + } return ret; } void CALLBACK -RundllEntryPoint(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow) +RundllEntryPoint(HWND hwnd, + HINSTANCE hinst, + LPSTR lpszCmdLine, + int nCmdShow) { - int in, out; + int in; + int out; sscanf(lpszCmdLine, "%u %u", &in, &out); - setmode (in, _O_BINARY); setmode (out, _O_BINARY); - - process_requests (read_plugin_data (in), in, out); + process_requests (read_plugin_data (in), + in, out); } #endif @@ -1805,6 +1857,7 @@ decompress_and_extract (struct EXTRACTOR_PluginList *plugins, EXTRACTOR_MetaDataProcessor proc, void *proc_cls) { unsigned char * buf; + unsigned char * rbuf; size_t dsize; #if HAVE_ZLIB z_stream strm; @@ -1936,7 +1989,14 @@ decompress_and_extract (struct EXTRACTOR_PluginList *plugins, dsize *= 2; if (dsize > MAX_DECOMPRESS) dsize = MAX_DECOMPRESS; - buf = realloc(buf, dsize); + rbuf = realloc(buf, dsize); + if (rbuf == NULL) + { + free (buf); + buf = NULL; + break; + } + buf = rbuf; strm.next_out = (Bytef*) &buf[pos]; strm.avail_out = dsize - pos; } @@ -1950,10 +2010,12 @@ decompress_and_extract (struct EXTRACTOR_PluginList *plugins, (ret != Z_STREAM_END) ); dsize = pos + strm.total_out; inflateEnd(&strm); - if (dsize == 0) { - free(buf); - buf = NULL; - } + if ( (dsize == 0) && + (buf != NULL) ) + { + free(buf); + buf = NULL; + } } } } @@ -2005,7 +2067,14 @@ decompress_and_extract (struct EXTRACTOR_PluginList *plugins, dsize *= 2; if (dsize > MAX_DECOMPRESS) dsize = MAX_DECOMPRESS; - buf = realloc(buf, dsize); + rbuf = realloc(buf, dsize); + if (rbuf == NULL) + { + free (buf); + buf = NULL; + break; + } + buf = rbuf; bstrm.next_out = (char*) &buf[bpos]; bstrm.avail_out = dsize - bpos; } @@ -2019,7 +2088,8 @@ decompress_and_extract (struct EXTRACTOR_PluginList *plugins, (bret != BZ_STREAM_END) ); dsize = bpos + bstrm.total_out_lo32; BZ2_bzDecompressEnd(&bstrm); - if (dsize == 0) + if ( (dsize == 0) && + (buf != NULL) ) { free(buf); buf = NULL; diff --git a/src/main/extractor_print.c b/src/main/extractor_print.c @@ -59,12 +59,19 @@ EXTRACTOR_meta_data_print(void * handle, if (cd == (iconv_t) -1) return 1; buf = iconv_helper(cd, data); - ret = fprintf(handle, - "%s - %s\n", - dgettext ("libextractor", - EXTRACTOR_metatype_to_string (type)), - buf); - free(buf); + if (buf != NULL) + { + ret = fprintf(handle, + "%s - %s\n", + dgettext ("libextractor", + EXTRACTOR_metatype_to_string (type)), + buf); + free(buf); + } + else + { + ret = -1; + } iconv_close(cd); if (ret < 0) return 1; diff --git a/src/main/iconv.c b/src/main/iconv.c @@ -40,6 +40,8 @@ iconv_helper(iconv_t cd, outSize = 4 * strlen(in) + 2; outLeft = outSize - 2; /* make sure we have 2 0-terminations! */ buf = malloc(outSize); + if (buf == NULL) + return NULL; ibuf = buf; memset(buf, 0, outSize); if (iconv(cd, diff --git a/src/plugins/gif_extractor.c b/src/plugins/gif_extractor.c @@ -153,7 +153,6 @@ parseComment (const unsigned char *data, { size_t length = 0; size_t curr = pos; - char *comment; int ret; while ((data[curr] != 0) && (curr < size)) @@ -161,26 +160,32 @@ parseComment (const unsigned char *data, length += data[curr]; curr += data[curr] + 1; } - comment = malloc (length + 1); - curr = pos; - length = 0; - while ((data[curr] != 0) && (curr < size)) + if (length < 65536) { - length += data[curr]; - if (length >= size) - break; - memcpy (&comment[length - data[curr]], &data[curr] + 1, data[curr]); - comment[length] = '\0'; - curr += data[curr] + 1; + char comment[length+1]; + curr = pos; + length = 0; + while ((data[curr] != 0) && (curr < size)) + { + length += data[curr]; + if (length >= size) + break; + memcpy (&comment[length - data[curr]], &data[curr] + 1, data[curr]); + comment[length] = '\0'; + curr += data[curr] + 1; + } + ret = proc (proc_cls, + "gif", + EXTRACTOR_METATYPE_COMMENT, + EXTRACTOR_METAFORMAT_UTF8, + "text/plain", + comment, + length+1); + } + else + { + ret = 0; } - ret = proc (proc_cls, - "gif", - EXTRACTOR_METATYPE_COMMENT, - EXTRACTOR_METAFORMAT_UTF8, - "text/plain", - comment, - length+1); - free (comment); return ret; } diff --git a/src/plugins/html_extractor.c b/src/plugins/html_extractor.c @@ -205,6 +205,8 @@ findInTags (TagInfo * t, if (pstart != NULL) { char *ret = malloc (pend - pstart + 1); + if (ret == NULL) + return NULL; memcpy (ret, pstart, pend - pstart); ret[pend - pstart] = '\0'; return ret; @@ -290,6 +292,8 @@ EXTRACTOR_html_extract (const char *data, tag.tagStart, tag.tagEnd - tag.tagStart))) { t = malloc (sizeof (TagInfo)); + if (t == NULL) + return 0; *t = tag; t->next = tags; tags = t; @@ -357,7 +361,8 @@ EXTRACTOR_html_extract (const char *data, free (xtmp); } } - free (tmp); + if (tmp != NULL) + free (tmp); i++; } while (tags != NULL) @@ -369,16 +374,19 @@ EXTRACTOR_html_extract (const char *data, if (charset == NULL) { xtmp = malloc (t->dataEnd - t->dataStart + 1); - memcpy (xtmp, t->dataStart, t->dataEnd - t->dataStart); - xtmp[t->dataEnd - t->dataStart] = '\0'; - ret = proc (proc_cls, - "html", - EXTRACTOR_METATYPE_TITLE, - EXTRACTOR_METAFORMAT_C_STRING, - "text/plain", - xtmp, - strlen (xtmp) + 1); - free (xtmp); + if (xtmp != NULL) + { + memcpy (xtmp, t->dataStart, t->dataEnd - t->dataStart); + xtmp[t->dataEnd - t->dataStart] = '\0'; + ret = proc (proc_cls, + "html", + EXTRACTOR_METATYPE_TITLE, + EXTRACTOR_METAFORMAT_C_STRING, + "text/plain", + xtmp, + strlen (xtmp) + 1); + free (xtmp); + } } else { diff --git a/src/plugins/id3v23_extractor.c b/src/plugins/id3v23_extractor.c @@ -356,8 +356,9 @@ EXTRACTOR_id3v23_extract (const unsigned char *data, (data[pos+off] != '\0') ) return 0; /* malformed */ off++; - if (0 == strcasecmp ("-->", - mime)) + if ( (mime != NULL) && + (0 == strcasecmp ("-->", + mime)) ) { /* not supported */ } @@ -371,11 +372,13 @@ EXTRACTOR_id3v23_extract (const unsigned char *data, (const char*) &data[pos + off], csize + 6 - off)) { - free (mime); + if (mime != NULL) + free (mime); return 1; } } - free (mime); + if (mime != NULL) + free (mime); word = NULL; break; default: @@ -395,7 +398,8 @@ EXTRACTOR_id3v23_extract (const unsigned char *data, return 1; } } - free (word); + if (word != NULL) + free (word); break; } i++; diff --git a/src/plugins/id3v24_extractor.c b/src/plugins/id3v24_extractor.c @@ -366,8 +366,9 @@ EXTRACTOR_id3v24_extract (const unsigned char *data, (data[pos+off] != '\0') ) return 0; /* malformed */ off++; - if (0 == strcasecmp ("-->", - mime)) + if ( (mime != NULL) && + (0 == strcasecmp ("-->", + mime)) ) { /* not supported */ } @@ -381,11 +382,13 @@ EXTRACTOR_id3v24_extract (const unsigned char *data, (const char*) &data[pos + off], csize + 6 - off)) { - free (mime); + if (mime != NULL) + free (mime); return 1; } } - free (mime); + if (mime != NULL) + free (mime); word = NULL; break; default: @@ -405,7 +408,8 @@ EXTRACTOR_id3v24_extract (const unsigned char *data, return 1; } } - free (word); + if (word != NULL) + free (word); break; } i++; diff --git a/src/plugins/id3v2_extractor.c b/src/plugins/id3v2_extractor.c @@ -347,7 +347,8 @@ EXTRACTOR_id3v2_extract (const unsigned char *data, return 1; } } - free (word); + if (word != NULL) + free (word); break; } i++; diff --git a/src/plugins/ole2_extractor.c b/src/plugins/ole2_extractor.c @@ -430,6 +430,8 @@ history_extract(GsfInput * stream, if (gsf_input_remaining(stream) < lcbSttbSavedBy) return 0; lbuffer = malloc(lcbSttbSavedBy); + if (lbuffer == NULL) + return 0; // read all the revision history gsf_input_read(stream, lcbSttbSavedBy, lbuffer); // there are n strings, so n/2 revisions (author & file) @@ -444,29 +446,41 @@ history_extract(GsfInput * stream, (where + 2 * length + 2 <= where) ) break; author = EXTRACTOR_common_convert_to_utf8((const char*) &lbuffer[where], - length * 2, - "UTF-16BE"); + length * 2, + "UTF-16BE"); where += length * 2 + 1; length = lbuffer[where++]; if ( (where + 2 * length >= lcbSttbSavedBy) || (where + 2 * length + 1 <= where) ) { - free(author); + if (author != NULL) + free(author); break; } filename = EXTRACTOR_common_convert_to_utf8((const char*) &lbuffer[where], - length * 2, - "UTF-16BE"); + length * 2, + "UTF-16BE"); where += length * 2 + 1; - rbuf = malloc(strlen(author) + strlen(filename) + 512); - snprintf(rbuf, 512 + strlen(author) + strlen(filename), - _("Revision #%u: Author '%s' worked on '%s'"), - i, author, filename); - free(author); - free(filename); - ret = addKeyword(proc, proc_cls, - rbuf, - EXTRACTOR_METATYPE_REVISION_HISTORY); - free(rbuf); + if ( (author != NULL) && + (filename != NULL) ) + { + rbuf = malloc(strlen(author) + strlen(filename) + 512); + if (rbuf != NULL) + { + snprintf(rbuf, + 512 + strlen(author) + strlen(filename), + _("Revision #%u: Author '%s' worked on '%s'"), + i, author, filename); + ret = addKeyword(proc, proc_cls, + rbuf, + EXTRACTOR_METATYPE_REVISION_HISTORY); + if (rbuf != NULL) + free(rbuf); + } + } + if (author != NULL) + free(author); + if (filename != NULL) + free(filename); if (0 != ret) break; } diff --git a/src/plugins/pdf_extractor.cc b/src/plugins/pdf_extractor.cc @@ -56,6 +56,8 @@ printInfoString(Dict *infoDict, int err = 0; char * result; + if (ckey == NULL) + return 0; result = NULL; if (infoDict->lookup(ckey, &obj)->isString()) { s1 = obj.getString(); @@ -63,7 +65,8 @@ printInfoString(Dict *infoDict, if ((((unsigned char)s[0]) & 0xff) == 0xfe && (((unsigned char)s[1]) & 0xff) == 0xff) { result = EXTRACTOR_common_convert_to_utf8(&s[2], s1->getLength() - 2, "UTF-16BE"); - ADD (result, type); + if (result != NULL) + ADD (result, type); } else { size_t len = strlen(s); @@ -95,13 +98,15 @@ printInfoString(Dict *infoDict, if (0 < len) { result = EXTRACTOR_common_convert_to_utf8(s, len, "ISO-8859-1"); - ADD (result, type); + if (result != NULL) + ADD (result, type); } } } EXIT: obj.free(); - free (result); + if (result != NULL) + free (result); free (ckey); return err; } @@ -123,6 +128,8 @@ printInfoDate(Dict *infoDict, err = 0; result = NULL; gkey = strdup (key); + if (gkey == NULL) + return 0; if (infoDict->lookup(gkey, &obj)->isString()) { s1 = obj.getString(); s = s1->getCString(); @@ -132,7 +139,8 @@ printInfoDate(Dict *infoDict, /* isUnicode */ result = EXTRACTOR_common_convert_to_utf8((const char*)&s[2], s1->getLength() - 2, "UTF-16BE"); - ADD (result, type); + if (result != NULL) + ADD (result, type); } else { if (s[0] == 'D' && s[1] == ':') s += 2; @@ -143,7 +151,8 @@ printInfoDate(Dict *infoDict, } EXIT: obj.free(); - free (result); + if (result != NULL) + free (result); free (gkey); return err; } diff --git a/src/plugins/ps_extractor.c b/src/plugins/ps_extractor.c @@ -154,7 +154,8 @@ EXTRACTOR_ps_extract (const char *data, while ( (line == NULL) || (0 != strncmp ("%%EndComments", line, strlen ("%%EndComments"))) ) { - free (line); + if (line != NULL) + free (line); line = readline (data, size, pos); if (line == NULL) break; @@ -186,7 +187,8 @@ EXTRACTOR_ps_extract (const char *data, break; /* overflow */ pos += strlen (line) + 1; /* skip newline, too; guarantee progress! */ } - free (line); + if (line != NULL) + free (line); return ret; } diff --git a/src/plugins/zip_extractor.c b/src/plugins/zip_extractor.c @@ -88,7 +88,7 @@ EXTRACTOR_zip_extract (const unsigned char *data, void *tmp; zip_entry * info; zip_entry * start; - char *filecomment = NULL; + char *filecomment; const unsigned char *pos; unsigned int offset, stop; unsigned int name_length, extra_length, comment_length; @@ -174,8 +174,11 @@ EXTRACTOR_zip_extract (const unsigned char *data, if (filecomment_length > 0) { filecomment = malloc (filecomment_length + 1); - memcpy (filecomment, &pos[22], filecomment_length); - filecomment[filecomment_length] = '\0'; + if (filecomment != NULL) + { + memcpy (filecomment, &pos[22], filecomment_length); + filecomment[filecomment_length] = '\0'; + } } if ((0 != pos[4]) && (0 != pos[5])) { @@ -281,12 +284,16 @@ EXTRACTOR_zip_extract (const unsigned char *data, if (start == NULL) { start = malloc (sizeof (zip_entry)); + if (start == NULL) + break; start->next = NULL; info = start; } else { info->next = malloc (sizeof (zip_entry)); + if (info->next == NULL) + break; info = info->next; info->next = NULL; } @@ -294,35 +301,36 @@ EXTRACTOR_zip_extract (const unsigned char *data, info->comment = malloc (comment_length + 1); /* (strings in zip files are not null terminated) */ - memcpy (info->filename, &pos[46], name_length); - info->filename[name_length] = '\0'; - memcpy (info->comment, &pos[46 + name_length + extra_length], - comment_length); - info->comment[comment_length] = '\0'; - -#if DEBUG_EXTRACT_ZIP - fprintf (stderr, "Found file %s, Comment: %s\n", info->filename, - info->comment); - -#endif - offset += 46 + name_length + extra_length + comment_length; - pos = &data[offset]; - - /* check for next header entry (0x02014b50) or (0x06054b50) if at end */ - if (('P' != pos[0]) && ('K' != pos[1])) + if (info->filename != NULL) + { + memcpy (info->filename, &pos[46], name_length); + info->filename[name_length] = '\0'; + } + if (info->comment != NULL) + { + memcpy (info->comment, &pos[46 + name_length + extra_length], + comment_length); + info->comment[comment_length] = '\0'; + } + offset += 46 + name_length + extra_length + comment_length; + pos = &data[offset]; + /* check for next header entry (0x02014b50) or (0x06054b50) if at end */ + if (('P' != pos[0]) && ('K' != pos[1])) { - + #if DEBUG_EXTRACT_ZIP - fprintf (stderr, - "Did not find next header in central directory.\n"); + fprintf (stderr, + "Did not find next header in central directory.\n"); #endif - info = start; + info = start; while (info != NULL) { start = info->next; - free (info->filename); - free (info->comment); + if (info->filename != NULL) + free (info->filename); + if (info->comment != NULL) + free (info->comment); free (info); info = start; } @@ -364,7 +372,8 @@ EXTRACTOR_zip_extract (const unsigned char *data, filecomment, strlen (filecomment)+1); } - free (filecomment); + if (filecomment != NULL) + free (filecomment); /* if we've gotten to here then there is at least one zip entry (see get_zipinfo call above) */