From 9b1d07ba6ed79d2b32b1e8fa92bd93628f66b1c0 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 25 Jan 2019 09:31:34 +0100 Subject: partialator: Fix multiple memory leaks --- libcrystfel/src/reflist.c | 1 + libcrystfel/src/stream.c | 12 ++++++++++++ libcrystfel/src/stream.h | 2 ++ 3 files changed, 15 insertions(+) (limited to 'libcrystfel') diff --git a/libcrystfel/src/reflist.c b/libcrystfel/src/reflist.c index f1d759ea..9c8a6a14 100644 --- a/libcrystfel/src/reflist.c +++ b/libcrystfel/src/reflist.c @@ -233,6 +233,7 @@ void reflist_free(RefList *list) if ( list->head != NULL ) { recursive_free(list->head); } /* else empty list */ + if ( list->notes != NULL ) free(list->notes); free(list); } diff --git a/libcrystfel/src/stream.c b/libcrystfel/src/stream.c index bcd2627e..66b3b657 100644 --- a/libcrystfel/src/stream.c +++ b/libcrystfel/src/stream.c @@ -1131,6 +1131,18 @@ static void read_crystal(Stream *st, struct image *image, StreamReadFlags srf) } +void free_stuff_from_stream(struct stuff_from_stream *sfs) +{ + int i; + if ( sfs == NULL ) return; + for ( i=0; in_fields; i++ ) { + free(sfs->fields[i]); + } + free(sfs->fields); + free(sfs); +} + + static int read_and_store_field(struct image *image, const char *line) { char **new_fields; diff --git a/libcrystfel/src/stream.h b/libcrystfel/src/stream.h index a8e3e2ee..bd7aa690 100644 --- a/libcrystfel/src/stream.h +++ b/libcrystfel/src/stream.h @@ -106,6 +106,8 @@ extern Stream *open_stream_fd_for_write(int fd); extern int get_stream_fd(Stream *st); extern void close_stream(Stream *st); +extern void free_stuff_from_stream(struct stuff_from_stream *sfs); + extern int read_chunk(Stream *st, struct image *image); extern int read_chunk_2(Stream *st, struct image *image, StreamReadFlags srf); -- cgit v1.2.3