浏览代码

Check a return value for errors.

Catches bad input data found during fuzzing.
Ryan C. Gordon 5 年之前
父节点
当前提交
eb4b057f0d
共有 1 个文件被更改,包括 1 次插入0 次删除
  1. 1 0
      stb_image.h

+ 1 - 0
stb_image.h

@@ -2168,6 +2168,7 @@ static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__
       // first scan for DC coefficient, must be first
       // first scan for DC coefficient, must be first
       memset(data,0,64*sizeof(data[0])); // 0 all the ac values now
       memset(data,0,64*sizeof(data[0])); // 0 all the ac values now
       t = stbi__jpeg_huff_decode(j, hdc);
       t = stbi__jpeg_huff_decode(j, hdc);
+      if (t == -1) return stbi__err("can't merge dc and ac", "Corrupt JPEG");
       diff = t ? stbi__extend_receive(j, t) : 0;
       diff = t ? stbi__extend_receive(j, t) : 0;
 
 
       dc = j->img_comp[b].dc_pred + diff;
       dc = j->img_comp[b].dc_pred + diff;