Skip to content
Permalink
Browse files

Revert "simplify recent bug fix"

This reverts commit bbfddaa.

the fd will be leaked
  • Loading branch information...
shawnl committed Apr 14, 2019
1 parent bbfddaa commit 25b7f89875c303f01754557e82e08a6c052875d8
Showing with 5 additions and 3 deletions.
  1. +5 −3 src/stringmap.c
@@ -48,13 +48,15 @@ stringmap_t *stringmap_load(const char *filename, int numFinalWordsToMatch)
char buf[2*PATH_MAX];
int n;

fp = fopen(filename, "r");
if (!fp)
return NULL;
result = calloc(1, sizeof(*result));
if (!result)
return NULL;
result->numFinalWordsToMatch = numFinalWordsToMatch;
fp = fopen(filename, "r");
if (!fp) {
free(result);
return NULL;
}
n=0;
while (fgets(buf, sizeof(buf), fp))
n++;

0 comments on commit 25b7f89

Please sign in to comment.
You can’t perform that action at this time.