Skip to content

Commit

Permalink
Revert "simplify recent bug fix"
Browse files Browse the repository at this point in the history
This reverts commit bbfddaa.

the fd will be leaked
  • Loading branch information
shawnl committed Apr 14, 2019
1 parent bbfddaa commit 25b7f89
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/stringmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down

0 comments on commit 25b7f89

Please sign in to comment.