Skip to content

Commit

Permalink
fix: memory leaks
Browse files Browse the repository at this point in the history
some code don't free allocated memory.
  • Loading branch information
safocl committed Jan 30, 2025
1 parent 75dcdc2 commit a83b017
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
12 changes: 6 additions & 6 deletions ntfsprogs/ntfsfix.c
Original file line number Diff line number Diff line change
Expand Up @@ -1204,11 +1204,11 @@ static int fix_self_located_mft(ntfs_volume *vol)
ntfs_log_info(OK);
res = -1;
}
free(selfloc.mft0);
free(selfloc.mft1);
free(selfloc.mft2);
free(selfloc.attrlist);
}
free(selfloc.mft0);
free(selfloc.mft1);
free(selfloc.mft2);
free(selfloc.attrlist);
return (res);
}

Expand Down Expand Up @@ -1421,10 +1421,10 @@ static int check_alternate_boot(ntfs_volume *vol)
} else {
ntfs_log_info("Error : could not read the boot sector again\n");
}
free(full_bs);
free(alt_bs);

error_exit :
free(full_bs);
free(alt_bs);
return (res);
}

Expand Down
7 changes: 5 additions & 2 deletions ntfsprogs/ntfsusermap.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ static boolean outputmap(const char *volume, const char *dir)
char buf[256];
int fn;
char *fullname;
char *backup;
char *backup = NULL;
struct USERMAPPING *mapping;
boolean done;
boolean err;
Expand Down Expand Up @@ -895,6 +895,8 @@ static boolean outputmap(const char *volume, const char *dir)
if (!done)
fprintf(stderr, "* Could not create mapping file \"%s\"\n",
fullname);
free(backup);
free(fullname);
return (done);
}

Expand Down Expand Up @@ -1005,7 +1007,8 @@ static boolean sanitize(void)
group->defined = AGREED;
group->next = firstmapping;
firstmapping = group;
}
} else
free(group);
}
}
}
Expand Down

0 comments on commit a83b017

Please sign in to comment.