]> granicus.if.org Git - libjpeg-turbo/commitdiff
Ensure that libjpeg state is reset if an error occurs
authorDRC <dcommander@users.sourceforge.net>
Thu, 24 Feb 2011 21:16:10 +0000 (21:16 +0000)
committerDRC <dcommander@users.sourceforge.net>
Thu, 24 Feb 2011 21:16:10 +0000 (21:16 +0000)
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.1.x@437 632fc199-4ca6-4c93-a231-07263d6284db

turbojpegl.c

index c1c62f6ee6368b1119c121b3f513c445d90c7599..7dd6a41a796b73343b2644be4e3a7e7d45d26089 100644 (file)
@@ -294,6 +294,7 @@ DLLEXPORT int DLLCALL tjCompress(tjhandle h,
                        -(unsigned long)(j->jdms.free_in_buffer);
 
        bailout:
+       if(j->cinfo.global_state>CSTATE_START) jpeg_abort_compress(&j->cinfo);
        if(row_pointer) free(row_pointer);
        for(i=0; i<MAX_COMPONENTS; i++)
        {
@@ -576,6 +577,7 @@ DLLEXPORT int DLLCALL tjDecompress(tjhandle h,
        jpeg_finish_decompress(&j->dinfo);
 
        bailout:
+       if(j->dinfo.global_state>DSTATE_START) jpeg_abort_decompress(&j->dinfo);
        for(i=0; i<MAX_COMPONENTS; i++)
        {
                if(tmpbuf[i]) free(tmpbuf[i]);