From: Michihiro NAKAJIMA Date: Sun, 7 Oct 2012 21:21:49 +0000 (+0900) Subject: Fix potential memory leaks found with Clang. X-Git-Tag: v3.1.0~40^2~76 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0eca73efb98da4c0afee1dec010e007108ab3ee5;p=thirdparty%2Flibarchive.git Fix potential memory leaks found with Clang. --- diff --git a/libarchive/archive_read_support_filter_program.c b/libarchive/archive_read_support_filter_program.c index 5b052d7cb..344f5a989 100644 --- a/libarchive/archive_read_support_filter_program.c +++ b/libarchive/archive_read_support_filter_program.c @@ -650,8 +650,10 @@ __archive_read_programv(struct archive_read_filter *self, const char *cmd, archive_string_ensure(&state->description, l) == NULL) { archive_set_error(&self->archive->archive, ENOMEM, "Can't allocate input data"); - archive_string_free(&state->description); - free(state); + if (state != NULL) { + archive_string_free(&state->description); + free(state); + } free(out_buf); return (ARCHIVE_FATAL); } diff --git a/libarchive/archive_write_add_filter_program.c b/libarchive/archive_write_add_filter_program.c index 3dda6bae0..dc72d39b1 100644 --- a/libarchive/archive_write_add_filter_program.c +++ b/libarchive/archive_write_add_filter_program.c @@ -226,6 +226,7 @@ write_add_filter_programv(struct archive *_a, const char *cmd, f->free = archive_compressor_program_free; return (ARCHIVE_OK); memerr: + free(data); archive_compressor_program_free(f); archive_set_error(_a, ENOMEM, "Can't allocate memory for filter program");