libextractor

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

commit 663feac13cbdba5299dbb32ed3a19617a5eb6538
parent 8b9fc8ed8c98d5a72750f856e5442749d6d85b68
Author: Christian Grothoff <christian@grothoff.org>
Date:   Fri, 19 Jan 2007 23:44:56 +0000

minor bugfixes

Diffstat:
Msrc/main/extract.c | 5++++-
Msrc/main/extractor.c | 58++++++++++++++++++++++++++--------------------------------
Msrc/plugins/lowerextractor.c | 4++--
Msrc/plugins/nsfeextractor.c | 5+----
Msrc/plugins/ole2/ole2extractor.c | 8+++++---
Msrc/plugins/printable/dictionary-builder.c | 5+++--
Msrc/plugins/qtextractor.c | 2+-
Msrc/plugins/rpm/rpmextractor.c | 2+-
Msrc/plugins/tarextractor.c | 1+
Msrc/plugins/zipextractor.c | 18+++++++++---------
10 files changed, 53 insertions(+), 55 deletions(-)

diff --git a/src/main/extract.c b/src/main/extract.c @@ -405,7 +405,10 @@ printSelectedKeywordsBibtex (FILE * handle, if ( pages ) fprintf(handle, " pages = \"%s\"%s\n", pages, (last == pages)?"":","); - + if (month != NULL) + free(month); + if (year != NULL) + free(year); fprintf(handle, "}\n\n"); } } diff --git a/src/main/extractor.c b/src/main/extractor.c @@ -1247,8 +1247,7 @@ removeKeyword (const char *keyword, const EXTRACTOR_KeywordType type, const unsigned int options, EXTRACTOR_KeywordList ** list, - EXTRACTOR_KeywordList * current) -{ + EXTRACTOR_KeywordList * current) { EXTRACTOR_KeywordList *first; EXTRACTOR_KeywordList *pos; EXTRACTOR_KeywordList *prev; @@ -1257,37 +1256,32 @@ removeKeyword (const char *keyword, first = *list; pos = first; prev = NULL; - while (pos != NULL) - { - if (pos == current) - { - prev = pos; - pos = current->next; - } - if (pos == NULL) - break; - if ( (0 == strcmp (pos->keyword, keyword)) && - ( (pos->keywordType == type) || - (((options & EXTRACTOR_DUPLICATES_TYPELESS) > 0)) || - ( ((options & EXTRACTOR_DUPLICATES_REMOVE_UNKNOWN) > 0) && - (pos->keywordType == EXTRACTOR_UNKNOWN)) ) ) - { - /* remove! */ - if (prev == NULL) - first = pos->next; - else - prev->next = pos->next; - next = pos->next; - free (pos->keyword); - free (pos); - pos = next; - } + while (pos != NULL) { + if (pos == current) { + prev = pos; + pos = current->next; + } + if (pos == NULL) + break; + if ( (0 == strcmp (pos->keyword, keyword)) && + ( (pos->keywordType == type) || + (((options & EXTRACTOR_DUPLICATES_TYPELESS) > 0)) || + ( ((options & EXTRACTOR_DUPLICATES_REMOVE_UNKNOWN) > 0) && + (pos->keywordType == EXTRACTOR_UNKNOWN)) ) ) { + /* remove! */ + if (prev == NULL) + first = pos->next; else - { - prev = pos; - pos = pos->next; - } - } /* end while */ + prev->next = pos->next; + next = pos->next; + free (pos->keyword); + free (pos); + pos = next; + } else { + prev = pos; + pos = pos->next; + } + } /* end while */ *list = first; } diff --git a/src/plugins/lowerextractor.c b/src/plugins/lowerextractor.c @@ -43,7 +43,7 @@ libextractor_lower_extract(char * filename, unsigned int mem, needed, i; pos = prev; - lower = 0; + lower = NULL; mem = 0; while (pos != NULL) @@ -51,7 +51,7 @@ libextractor_lower_extract(char * filename, needed = strlen(pos->keyword) + 1; if (needed > mem) { - lower = (char *) (lower) ? realloc(lower, needed) : malloc(needed); + lower = (lower == NULL) ? realloc(lower, needed) : malloc(needed); mem = needed; } diff --git a/src/plugins/nsfeextractor.c b/src/plugins/nsfeextractor.c @@ -88,10 +88,7 @@ static char * nsfestring(const char * data, int size ) s = malloc( length + 1 ); - if( data != NULL ) - { - strncpy( s, data, length ); - } + strncpy( s, data, length ); s[ strlen( data ) ] = '\0'; diff --git a/src/plugins/ole2/ole2extractor.c b/src/plugins/ole2/ole2extractor.c @@ -156,11 +156,11 @@ static void processMetadata(gpointer key, /* convert other formats? */ contents = g_strdup_value_contents(gval); } + if (contents == NULL) + return; if ( (strlen(contents) > 0) && (contents[strlen(contents)-1] == '\n') ) contents[strlen(contents)-1] = '\0'; - if (contents == NULL) - return; pos = 0; while (tmap[pos].text != NULL) { if (0 == strcmp(tmap[pos].text, @@ -412,8 +412,10 @@ history_extract(GsfInput * stream, where += length * 2 + 1; length = lbuffer[where++]; if ( (where + 2 * length >= lcbSttbSavedBy) || - (where + 2 * length + 1 <= where) ) + (where + 2 * length + 1 <= where) ) { + free(author); break; + } filename = convertToUtf8((const char*) &lbuffer[where], length * 2, "UTF-16BE"); diff --git a/src/plugins/printable/dictionary-builder.c b/src/plugins/printable/dictionary-builder.c @@ -127,10 +127,10 @@ int main(int argc, words[cnt] = strdup(line); cnt++; memset(&line[0], 0, 2048); - if (cnt > ALLOCSIZE) { + if (cnt >= ALLOCSIZE) { fprintf(stderr, _("Increase ALLOCSIZE (in %s).\n"), - __FILE__); + __FILE__); exit(-1); } } @@ -206,5 +206,6 @@ int main(int argc, bn, ADDR_PER_ELEMENT, bf.bitArraySize); + free(charset); return 0; } diff --git a/src/plugins/qtextractor.c b/src/plugins/qtextractor.c @@ -558,7 +558,7 @@ static int processTextTag(const char * input, if (len + sizeof(InternationalText) > as) return 0; /* invalid */ lang = ntohs(txt->language); - if (lang > 138) + if (lang >= sizeof(languages) / sizeof(char*)) return 0; /* invalid */ addKeyword(EXTRACTOR_LANGUAGE, languages[lang], diff --git a/src/plugins/rpm/rpmextractor.c b/src/plugins/rpm/rpmextractor.c @@ -2705,7 +2705,7 @@ static void providePackageNVR(Header h) int_32 pFlags = RPMSENSE_EQUAL; const char ** provides = NULL; const char ** providesEVR = NULL; - rpmTagType pnt, pvt; + rpmTagType pnt, pvt = RPM_NULL_TYPE; int_32 * provideFlags = NULL; int providesCount; int i; diff --git a/src/plugins/tarextractor.c b/src/plugins/tarextractor.c @@ -805,6 +805,7 @@ libextractor_tar_extract(const char * filename, strcpy(format + format_length, " TAR"); prev = addKeyword(EXTRACTOR_FORMAT, format, prev); } + free(format); } } } diff --git a/src/plugins/zipextractor.c b/src/plugins/zipextractor.c @@ -372,16 +372,16 @@ libextractor_zip_extract(const char * filename, /* note: this free()'s the info list as it goes */ info = start; while (NULL != info) { - if (strlen(info->filename)){ - EXTRACTOR_KeywordList * keyword = malloc(sizeof(EXTRACTOR_KeywordList)); - keyword->next = prev; - keyword->keyword = strdup(info->filename); - keyword->keywordType = EXTRACTOR_FILENAME; - prev = keyword; - } - if (info->filename != NULL) + if (info->filename != NULL) { + if (strlen(info->filename)){ + EXTRACTOR_KeywordList * keyword = malloc(sizeof(EXTRACTOR_KeywordList)); + keyword->next = prev; + keyword->keyword = strdup(info->filename); + keyword->keywordType = EXTRACTOR_FILENAME; + prev = keyword; + } free(info->filename); - + } if (strlen(info->comment)){ EXTRACTOR_KeywordList * keyword = malloc(sizeof(EXTRACTOR_KeywordList)); keyword->next = prev;