Browse files

Fix a bug that Clang Static Analyzer complains that

"Dereference of null pointer".
  • Loading branch information...
1 parent 4c04c78 commit b58d814f581a181bac80f12f43820200206b6a56 @ggcueroad ggcueroad committed Nov 11, 2012
Showing with 7 additions and 4 deletions.
  1. +7 −4 libarchive/archive_write_add_filter_program.c
View
11 libarchive/archive_write_add_filter_program.c
@@ -160,10 +160,13 @@ archive_compressor_program_free(struct archive_write_filter *f)
{
struct private_data *data = (struct private_data *)f->data;
- free(data->cmd);
- archive_string_free(&data->description);
- __archive_write_program_free(data->pdata);
- free(data);
+ if (data) {
+ free(data->cmd);
+ archive_string_free(&data->description);
+ __archive_write_program_free(data->pdata);
+ free(data);
+ f->data = NULL;
+ }
return (ARCHIVE_OK);
}

0 comments on commit b58d814

Please sign in to comment.