From 895fd6d0d370d64df9dbb1bc53342c734a6933fc Mon Sep 17 00:00:00 2001 From: DRC Date: Fri, 28 Feb 2014 09:35:34 +0000 Subject: [PATCH] Fix unitialized value reported by valgrind (the upsampling routine used by 4:4:0 and 4:1:1 reads the value of component_index.) git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@1133 632fc199-4ca6-4c93-a231-07263d6284db --- turbojpeg.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/turbojpeg.c b/turbojpeg.c index ee412c1..0f0d110 100644 --- a/turbojpeg.c +++ b/turbojpeg.c @@ -1235,6 +1235,8 @@ DLLEXPORT int DLLCALL tjDecompress(tjhandle handle, unsigned char *jpegBuf, static int setDecodeDefaults(struct jpeg_decompress_struct *dinfo, int pixelFormat, int subsamp, int flags) { + int i; + dinfo->scale_num=dinfo->scale_denom=1; if(subsamp==TJSAMP_GRAY) @@ -1254,15 +1256,14 @@ static int setDecodeDefaults(struct jpeg_decompress_struct *dinfo, dinfo->comp_info[0].h_samp_factor=tjMCUWidth[subsamp]/8; dinfo->comp_info[0].v_samp_factor=tjMCUHeight[subsamp]/8; + dinfo->comp_info[0].component_index=0; dinfo->cur_comp_info[0]=&dinfo->comp_info[0]; - if(dinfo->num_components==3) - { - dinfo->comp_info[1].h_samp_factor=1; - dinfo->comp_info[1].v_samp_factor=1; - dinfo->cur_comp_info[1]=&dinfo->comp_info[1]; - dinfo->comp_info[2].h_samp_factor=1; - dinfo->comp_info[2].v_samp_factor=1; - dinfo->cur_comp_info[2]=&dinfo->comp_info[2]; + for(i=1; inum_components; i++) + { + dinfo->comp_info[i].h_samp_factor=1; + dinfo->comp_info[i].v_samp_factor=1; + dinfo->comp_info[i].component_index=i; + dinfo->cur_comp_info[i]=&dinfo->comp_info[i]; } return 0; -- 2.40.0