star-stl

Load STereo Lithography (StL) file format
git clone git://git.meso-star.fr/star-stl.git
Log | Files | Refs | README | LICENSE

commit 331f53cd4a9cd0471c7c2bc18343c1852879848e
parent b469f7f4660e95148b88fe9c9d29c38a658d8eed
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed, 23 Apr 2025 12:15:26 +0200

Fix memory leaks in tests

The child process used to test an unseekable stream through a pipe must
not exit after writing data: it must first release the unused sstl.

Diffstat:
Msrc/test_sstl_load_ascii.c | 4+++-
Msrc/test_sstl_load_binary.c | 3++-
2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/test_sstl_load_ascii.c b/src/test_sstl_load_ascii.c @@ -423,6 +423,8 @@ check_no_seekable_file(struct sstl* sstl) if(pid == 0) { /* Child process */ CHK(close(fd[0]) == 0); /* Close the unused input stream */ + CHK(sstl_ref_put(sstl) == RES_OK); /* Release the unused sstl */ + CHK(write(fd[1], stl, strlen(stl)) == (int)strlen(stl)); CHK(close(fd[1]) == 0); exit(0); @@ -432,7 +434,7 @@ check_no_seekable_file(struct sstl* sstl) float v[3]; FILE* fp = NULL; const char* filename = "Piped StL"; - CHK(close(fd[1]) == 0); /* Clse the unused output stream */ + CHK(close(fd[1]) == 0); /* Close the unused output stream */ CHK(fp = fdopen(fd[0], "r")); CHK(sstl_load_stream(sstl, fp, filename) == RES_BAD_ARG); diff --git a/src/test_sstl_load_binary.c b/src/test_sstl_load_binary.c @@ -348,6 +348,7 @@ check_no_seekable_file(struct sstl* sstl) const uint16_t nattrs = 0; CHK(close(fd[0]) == 0); /* Close the unused input stream */ + CHK(sstl_ref_put(sstl) == RES_OK); /* Release the unused sstl */ /* Write the binary StL */ CHK(write(fd[1], header, sizeof(header)) == sizeof(header)); @@ -364,7 +365,7 @@ check_no_seekable_file(struct sstl* sstl) } else { /* Parent process */ struct sstl_desc desc = SSTL_DESC_NULL; FILE* fp = NULL; - CHK(close(fd[1]) == 0); /* Clse the unused output stream */ + CHK(close(fd[1]) == 0); /* Close the unused output stream */ CHK(fp = fdopen(fd[0], "r")); CHK(sstl_load_stream(sstl, fp, "Piped StL") == RES_BAD_ARG);