Skip to content

Commit

Permalink
Merge pull request #1 from misko/master
Browse files Browse the repository at this point in the history
fix memory bug :(
  • Loading branch information
AlexeyAB authored Aug 27, 2018
2 parents 2acc776 + 4658a68 commit 769a42b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,9 @@ void run_detector(int argc, char **argv)
char buffer[255];
fp = fopen(obj_names, "r");
while (fgets(buffer, 255, (FILE*)fp)) {
names[obj_count] = calloc(strlen(buffer), sizeof(char));
names[obj_count] = calloc(strlen(buffer)+1, sizeof(char));
strcpy(names[obj_count], buffer);
names[obj_count][strlen(buffer) - 1] = 0;
names[obj_count][strlen(buffer) - 1] = '\0'; //remove newline
++obj_count;
}
fclose(fp);
Expand Down

0 comments on commit 769a42b

Please sign in to comment.