Skip to content

Commit

Permalink
Fix theorical integer overflows
Browse files Browse the repository at this point in the history
  • Loading branch information
colinleroy committed Nov 16, 2023
1 parent 22e5463 commit 4266385
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions camlibs/quicktake1x0/qtkn-decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ int qtkn_decode(unsigned char *raw, int width, int height, unsigned char **out)

len = qtk_ppm_size(width, height);

tmp = malloc(width * height * sizeof(unsigned short));
tmp = malloc((size_t)width * (size_t)height * sizeof(unsigned short));
if (tmp == NULL) {
free(header);
return GP_ERROR_NO_MEMORY;
}

tmp_c = malloc(width * height);
tmp_c = malloc((size_t)width * (size_t)height);
if (tmp_c == NULL) {
free(header);
free(tmp);
Expand Down
2 changes: 1 addition & 1 deletion camlibs/quicktake1x0/qtkt-decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ int qtkt_decode(unsigned char *raw, int width, int height, unsigned char **out)
}
}

tmp = malloc((width + 4) * (height + 4));
tmp = malloc((size_t)(width + 4) * (size_t)(height + 4));
if (tmp == NULL) {
free(header);
return GP_ERROR_NO_MEMORY;
Expand Down

0 comments on commit 4266385

Please sign in to comment.