Skip to content

Commit

Permalink
Remove excess checks before free()
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanAizek committed Feb 28, 2025
1 parent 55db144 commit 36d9596
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 28 deletions.
3 changes: 1 addition & 2 deletions compat/ioapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,7 @@ void mz_stream_ioapi_delete(void **stream) {
if (!stream)
return;
ioapi = (mz_stream_ioapi *)*stream;
if (ioapi)
free(ioapi);
free(ioapi);
*stream = NULL;
}

Expand Down
3 changes: 1 addition & 2 deletions mz_strm.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,6 @@ void mz_stream_raw_delete(void **stream) {
if (!stream)
return;
raw = (mz_stream_raw *)*stream;
if (raw)
free(raw);
free(raw);
*stream = NULL;
}
3 changes: 1 addition & 2 deletions mz_strm_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,7 @@ void mz_stream_buffered_delete(void **stream) {
if (!stream)
return;
buffered = (mz_stream_buffered *)*stream;
if (buffered)
free(buffered);
free(buffered);
*stream = NULL;
}

Expand Down
3 changes: 1 addition & 2 deletions mz_strm_bzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,7 @@ void mz_stream_bzip_delete(void **stream) {
if (!stream)
return;
bzip = (mz_stream_bzip *)*stream;
if (bzip)
free(bzip);
free(bzip);
*stream = NULL;
}

Expand Down
3 changes: 1 addition & 2 deletions mz_strm_lzma.c
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,7 @@ void mz_stream_lzma_delete(void **stream) {
if (!stream)
return;
lzma = (mz_stream_lzma *)*stream;
if (lzma)
free(lzma);
free(lzma);
*stream = NULL;
}

Expand Down
3 changes: 1 addition & 2 deletions mz_strm_os_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,7 @@ void mz_stream_os_delete(void **stream) {
if (!stream)
return;
posix = (mz_stream_posix *)*stream;
if (posix)
free(posix);
free(posix);
*stream = NULL;
}

Expand Down
3 changes: 1 addition & 2 deletions mz_strm_pkcrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,7 @@ void mz_stream_pkcrypt_delete(void **stream) {
if (!stream)
return;
pkcrypt = (mz_stream_pkcrypt *)*stream;
if (pkcrypt)
free(pkcrypt);
free(pkcrypt);
*stream = NULL;
}

Expand Down
7 changes: 2 additions & 5 deletions mz_strm_split.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,11 +404,8 @@ void mz_stream_split_delete(void **stream) {
return;
split = (mz_stream_split *)*stream;
if (split) {
if (split->path_cd)
free(split->path_cd);
if (split->path_disk)
free(split->path_disk);

free(split->path_cd);
free(split->path_disk);
free(split);
}
*stream = NULL;
Expand Down
3 changes: 1 addition & 2 deletions mz_strm_zlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,7 @@ void mz_stream_zlib_delete(void **stream) {
if (!stream)
return;
zlib = (mz_stream_zlib *)*stream;
if (zlib)
free(zlib);
free(zlib);
*stream = NULL;
}

Expand Down
3 changes: 1 addition & 2 deletions mz_strm_zstd.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,7 @@ void mz_stream_zstd_delete(void **stream) {
if (!stream)
return;
zstd = (mz_stream_zstd *)*stream;
if (zstd)
free(zstd);
free(zstd);
*stream = NULL;
}

Expand Down
7 changes: 2 additions & 5 deletions mz_zip.c
Original file line number Diff line number Diff line change
Expand Up @@ -1416,9 +1416,7 @@ void mz_zip_delete(void **handle) {
if (!handle)
return;
zip = (mz_zip *)*handle;
if (zip) {
free(zip);
}
free(zip);
*handle = NULL;
}

Expand Down Expand Up @@ -1560,8 +1558,7 @@ int32_t mz_zip_set_comment(void *handle, const char *comment) {
int32_t comment_size = 0;
if (!zip || !comment)
return MZ_PARAM_ERROR;
if (zip->comment)
free(zip->comment);
free(zip->comment);
comment_size = (int32_t)strlen(comment);
if (comment_size > UINT16_MAX)
return MZ_PARAM_ERROR;
Expand Down

0 comments on commit 36d9596

Please sign in to comment.