Skip to content

Commit

Permalink
Merge pull request #43 from uno20001/fix_mem_freeing_issue
Browse files Browse the repository at this point in the history
Fix free() issue
  • Loading branch information
Rudde authored Apr 21, 2020
2 parents 754793b + a653e6d commit 84bcb42
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion init.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,15 @@ static void set_absolute_file_path(struct metafile *m)

/* if the file_path is already an absolute path just
return that */
if (m->metainfo_file_path && *m->metainfo_file_path == DIRSEP_CHAR)
if (m->metainfo_file_path && *m->metainfo_file_path == DIRSEP_CHAR) {
/* we need to reallocate the string, because we want to be able to
* free() it in cleanup_metafile(), and that would not be possible
* if m->metainfo_file_path pointed to a string from argv[]
*/
m->metainfo_file_path = strdup(m->metainfo_file_path);
FATAL_IF0(m->metainfo_file_path == NULL, "out of memory\n");
return;
}

/* first get the current working directory
using getcwd is a bit of a PITA */
Expand Down

0 comments on commit 84bcb42

Please sign in to comment.