Skip to content

Commit a3e2c28

Browse files
committed
fixed a memory leak in libstemmer.c
1 parent 943deea commit a3e2c28

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/libs/stemmer/libstemmer/libstemmer.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ sb_stemmer_new(const char * algorithm, const char * charenc)
4040
(struct sb_stemmer *) malloc(sizeof(struct sb_stemmer));
4141
if (stemmer == NULL) return NULL;
4242
enc = sb_getenc(charenc);
43-
if (enc == ENC_UNKNOWN) return NULL;
43+
if (enc == ENC_UNKNOWN){
44+
free(stemmer);
45+
return NULL;
46+
}
4447

4548
for (module = modules; module->name != 0; module++) {
4649
if (strcmp(module->name, algorithm) == 0 && module->enc == enc) break;

0 commit comments

Comments
 (0)