Skip to content

Commit

Permalink
compression: Add and fix null checks
Browse files Browse the repository at this point in the history
CID #58406, #200016, #58416

(cherry picked from commit 8cfb66b)
  • Loading branch information
oanatitoc authored and razvancrainea committed Oct 1, 2024
1 parent 44d9edd commit 1bd8d14
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions modules/compression/compression.c
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,8 @@ static int mc_compact_cb(char** buf_p, struct mc_compact_args *mc_compact_args,
memerr:
LM_ERR("No more pkg mem\n");
free_mem:
free_hdr_mask(hdr_mask);
if (hdr_mask != NULL)
free_hdr_mask(hdr_mask);
return -1;
}

Expand Down Expand Up @@ -1733,7 +1734,7 @@ static int mc_decompress(struct sip_msg* msg)
/*If compressed with this module there are great chances that Content-Encoding is last*/
hdr_vec[3] = msg->last_header;

if (!is_content_encoding(hdr_vec[3])) {
if (hdr_vec[3] && !is_content_encoding(hdr_vec[3])) {
hdr_vec[3] = NULL;
for (hf = msg->headers; hf; hf = hf->next) {
if (is_content_encoding(hf)) {
Expand Down
2 changes: 1 addition & 1 deletion modules/compression/gz_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ int gzip_compress(unsigned char* in, unsigned long ilen, str* out, unsigned long
if (!out->s) {
out->s = pkg_malloc(neededSize);
out->len = neededSize;
if (!out)
if (!out->s)
goto memerr;
} else if (ilen > out->len) {
out->s = pkg_realloc(out->s, neededSize);
Expand Down

0 comments on commit 1bd8d14

Please sign in to comment.