Skip to content

Commit

Permalink
Merge pull request #142 from Gottox/fix/metablock-memleak
Browse files Browse the repository at this point in the history
metablock_iterator: fix memory leak
  • Loading branch information
Gottox committed Sep 17, 2023
2 parents 3132004 + 901a4d9 commit c0c75b0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lib/read/metablock/metablock_iterator.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ map_data(struct SqshMetablockIterator *iterator) {
goto out;
}

sqsh__extract_view_cleanup(&iterator->extract_view);
if (iterator->is_compressed) {
rv = sqsh__extract_view_init(
&iterator->extract_view, iterator->compression_manager,
Expand All @@ -133,8 +134,6 @@ sqsh__metablock_iterator_next(
struct SqshMetablockIterator *iterator, int *err) {
int rv = 0;

sqsh__extract_view_cleanup(&iterator->extract_view);

rv = process_next_header(iterator);
if (rv < 0) {
goto out;
Expand Down
1 change: 1 addition & 0 deletions test/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ sqsh_extended_test = [
'tools/read-chunk/tail.sh',
'tools/unpack/repack.sh',
'tools/unpack/pathtraversal/pathtraversal.sh',
'tools/ls/large-tree.sh',
]
sqsh_extended_fs_test = [
'tools/fs/large-file.sh',
Expand Down
34 changes: 34 additions & 0 deletions test/tools/ls/large-tree.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/sh -ex

######################################################################
# @author : Enno Boland ([email protected])
# @file : repack.sh
# @created : Friday Mar 17, 2023 15:11:09 CET
#
# @description : This script creates a squashfs image, mounts it, and
# repacks it from the mounted path.
######################################################################

: "${BUILD_DIR:?BUILD_DIR is not set}"
: "${MKSQUASHFS:?MKSQUASHFS is not set}"
: "${SOURCE_ROOT:?SOURCE_ROOT is not set}"
: "${SQSH_LS:?SQSH_UNPACK is not set}"

MKSQUASHFS_OPTS="-no-xattrs -noappend -all-root -mkfs-time 0"

WORK_DIR="$BUILD_DIR/unpack-repack"

mkdir -p "$WORK_DIR"
cd "$WORK_DIR"

mkdir -p "$PWD/empty"

for i in $(seq 1 3641); do
echo "dir$i d 777 0 0";
echo "dir$i/file c 776 0 0 100 1";
done > "$PWD/large_tree.pseudo";

# shellcheck disable=SC2086
$MKSQUASHFS "$PWD/empty" "$PWD/large_tree.squashfs" -pf "$PWD/large_tree.pseudo" \
$MKSQUASHFS_OPTS
exec $SQSH_LS -r "$PWD/large_tree.squashfs"

0 comments on commit c0c75b0

Please sign in to comment.