Skip to content

Commit

Permalink
Fix memory leaks
Browse files Browse the repository at this point in the history
Three more low-hanging fruits from the LeakSanitizer logs.
  • Loading branch information
Keve authored and bapt committed Nov 29, 2024
1 parent c916458 commit fd0251a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions libpkg/pkg_create.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ pkg_create_from_dir(struct pkg *pkg, const char *root,
flatsize += file->size;
}

free(file->sum);
file->sum = pkg_checksum_generate_file(fpath,
PKG_HASH_TYPE_SHA256_HEX);
if (file->sum == NULL) {
Expand Down
2 changes: 2 additions & 0 deletions src/updating.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ exec_updating(int argc, char **argv)

while (getline(&line, &linecap, fd) > 0) {
if (strspn(line, "0123456789:") == 9) {
free(dateline);
dateline = strdup(line);
found = 0;
head = 1;
Expand Down Expand Up @@ -384,6 +385,7 @@ exec_updating(int argc, char **argv)
pkgdb_release_lock(db, PKGDB_LOCK_READONLY);
pkgdb_close(db);
pkg_free(pkg);
free(line);
free(dateline);

return (retcode);
Expand Down

0 comments on commit fd0251a

Please sign in to comment.