Skip to content

Commit 08d818e

Browse files
committed
Fix memory leak in packbeam
The memory leak in `do_pack` prevented successful building with address sanitizer (`-fsanitize=address`) enabled Signed-off-by: Bartosz Błaszków <bartosz.blaszkow@swmansion.com>
1 parent 0848033 commit 08d818e

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3232
- ESP32: improved sntp sync speed from a cold boot.
3333
- Utilize reserved `phy_init` partition on ESP32 to store wifi calibration for faster connections.
3434
- Support for zero count in `lists:duplicate/2`.
35+
- packbeam: fix memory leak preventing building with address sanitizer
3536

3637
## [0.6.6] - Unreleased
3738

tools/packbeam/packbeam.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,14 @@ static int do_pack(int argc, char **argv, int is_archive, bool include_lines)
266266
if (avmpack_is_valid(file_data, file_size)) {
267267
void *result = avmpack_fold(pack, file_data, pack_beam_fun);
268268
if (result == NULL) {
269+
free(file_data);
269270
return EXIT_FAILURE;
270271
}
271272
} else {
272273
char *filename = basename(argv[i]);
273274
pack_beam_file(pack, file_data, file_size, filename, !is_archive && i == 1, include_lines);
274275
}
276+
free(file_data);
275277
}
276278

277279
add_module_header(pack, "end", END_OF_FILE);

0 commit comments

Comments
 (0)