Skip to content

Commit 8971c26

Browse files
committed
Merge pull request #1609 from bblaszkow06/fix/packbeam-memleak
Fix memory leak in `packbeam.c` These changes are made under both the "Apache 2.0" and the "GNU Lesser General Public License 2.1 or later" license terms (dual license). SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
2 parents bf92bfd + 08d818e commit 8971c26

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
@@ -38,6 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3838
- ESP32: improved sntp sync speed from a cold boot.
3939
- Utilize reserved `phy_init` partition on ESP32 to store wifi calibration for faster connections.
4040
- Support for zero count in `lists:duplicate/2`.
41+
- packbeam: fix memory leak preventing building with address sanitizer
4142

4243
## [0.6.6] - Unreleased
4344

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)