Zero-initialize stbi__jpeg to avoid intermittent errors found by fuzz-testing
This commit is contained in:
parent
47164e4086
commit
5cfc2a744a
@ -4008,6 +4008,7 @@ static void *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int re
|
|||||||
unsigned char* result;
|
unsigned char* result;
|
||||||
stbi__jpeg* j = (stbi__jpeg*) stbi__malloc(sizeof(stbi__jpeg));
|
stbi__jpeg* j = (stbi__jpeg*) stbi__malloc(sizeof(stbi__jpeg));
|
||||||
if (!j) return stbi__errpuc("outofmem", "Out of memory");
|
if (!j) return stbi__errpuc("outofmem", "Out of memory");
|
||||||
|
memset(j, 0, sizeof(stbi__jpeg));
|
||||||
STBI_NOTUSED(ri);
|
STBI_NOTUSED(ri);
|
||||||
j->s = s;
|
j->s = s;
|
||||||
stbi__setup_jpeg(j);
|
stbi__setup_jpeg(j);
|
||||||
@ -4021,6 +4022,7 @@ static int stbi__jpeg_test(stbi__context *s)
|
|||||||
int r;
|
int r;
|
||||||
stbi__jpeg* j = (stbi__jpeg*)stbi__malloc(sizeof(stbi__jpeg));
|
stbi__jpeg* j = (stbi__jpeg*)stbi__malloc(sizeof(stbi__jpeg));
|
||||||
if (!j) return stbi__err("outofmem", "Out of memory");
|
if (!j) return stbi__err("outofmem", "Out of memory");
|
||||||
|
memset(j, 0, sizeof(stbi__jpeg));
|
||||||
j->s = s;
|
j->s = s;
|
||||||
stbi__setup_jpeg(j);
|
stbi__setup_jpeg(j);
|
||||||
r = stbi__decode_jpeg_header(j, STBI__SCAN_type);
|
r = stbi__decode_jpeg_header(j, STBI__SCAN_type);
|
||||||
@ -4046,6 +4048,7 @@ static int stbi__jpeg_info(stbi__context *s, int *x, int *y, int *comp)
|
|||||||
int result;
|
int result;
|
||||||
stbi__jpeg* j = (stbi__jpeg*) (stbi__malloc(sizeof(stbi__jpeg)));
|
stbi__jpeg* j = (stbi__jpeg*) (stbi__malloc(sizeof(stbi__jpeg)));
|
||||||
if (!j) return stbi__err("outofmem", "Out of memory");
|
if (!j) return stbi__err("outofmem", "Out of memory");
|
||||||
|
memset(j, 0, sizeof(stbi__jpeg));
|
||||||
j->s = s;
|
j->s = s;
|
||||||
result = stbi__jpeg_info_raw(j, x, y, comp);
|
result = stbi__jpeg_info_raw(j, x, y, comp);
|
||||||
STBI_FREE(j);
|
STBI_FREE(j);
|
||||||
|
Loading…
Reference in New Issue
Block a user