Permalink
Browse files

Merge pull request #120 from OpenSmalltalk/jpeg_win64_fix

Fix issue 119 jpeg plugin crashes in Win64
  • Loading branch information...
nicolas-cellier-aka-nice committed Feb 21, 2017
2 parents cfc82d9 + e13cbb4 commit 9ffa643cb1df941206428e609b0f34d28085b36a
@@ -5,7 +5,7 @@
struct error_mgr2 {
struct jpeg_error_mgr pub; /* "public" fields */
- jmp_buf setjmp_buffer; /* for return to caller */
+ jmp_buf *setjmp_buffer; /* for return to caller */
};
typedef struct error_mgr2 * error_ptr2;
@@ -20,5 +20,5 @@ void error_exit (j_common_ptr cinfo)
error_ptr2 myerr = (error_ptr2) cinfo->err;
/* Return control to the setjmp point */
- longjmp(myerr->setjmp_buffer, 1);
+ longjmp(*myerr->setjmp_buffer, 1);
}
@@ -6,7 +6,7 @@
struct error_mgr2 {
struct jpeg_error_mgr pub; /* "public" fields */
- jmp_buf setjmp_buffer; /* for return to caller */
+ jmp_buf *setjmp_buffer; /* for return to caller */
};
typedef struct error_mgr2* error_ptr2;
@@ -54,9 +54,10 @@ primJPEGWriteImageonByteArrayformqualityprogressiveJPEGerrorMgrWriteScanlines(
error_ptr2 pjerr = (error_ptr2)jpegErrorMgr2Struct;
pcinfo->err = jpeg_std_error(&pjerr->pub);
+ pjerr->setjmp_buffer = (jmp_buf *) malloc(sizeof(jmp_buf));
pjerr->pub.error_exit = error_exit;
- if (setjmp(pjerr->setjmp_buffer)) {
+ if (setjmp(*pjerr->setjmp_buffer)) {
jpeg_destroy_compress(pcinfo);
*destinationSizePtr = 0;
@@ -133,6 +134,7 @@ primJPEGWriteImageonByteArrayformqualityprogressiveJPEGerrorMgrWriteScanlines(
jpeg_finish_compress(pcinfo);
jpeg_destroy_compress(pcinfo);
}
+ free(pjerr->setjmp_buffer);
}
void
@@ -152,9 +154,10 @@ primJPEGReadImagefromByteArrayonFormdoDitheringerrorMgrReadScanlines(
int ok = 1;
pcinfo->err = jpeg_std_error(&pjerr->pub);
+ pjerr->setjmp_buffer = (jmp_buf *) malloc(sizeof(jmp_buf));
pjerr->pub.error_exit = error_exit;
- if (setjmp(pjerr->setjmp_buffer)) {
+ if (setjmp(*pjerr->setjmp_buffer)) {
jpeg_destroy_decompress(pcinfo);
ok = 0;
}
@@ -280,6 +283,7 @@ primJPEGReadImagefromByteArrayonFormdoDitheringerrorMgrReadScanlines(
jpeg_finish_decompress(pcinfo);
jpeg_destroy_decompress(pcinfo);
}
+ free(pjerr->setjmp_buffer);
}
void
@@ -293,9 +297,10 @@ primJPEGReadHeaderfromByteArraysizeerrorMgrReadHeader(
error_ptr2 pjerr = (error_ptr2)jpegErrorMgr2Struct;
pcinfo->err = jpeg_std_error(&pjerr->pub);
+ pjerr->setjmp_buffer = (jmp_buf *) malloc(sizeof(jmp_buf));
pjerr->pub.error_exit = error_exit;
- if (setjmp(pjerr->setjmp_buffer)) {
+ if (setjmp(*pjerr->setjmp_buffer)) {
jpeg_destroy_decompress(pcinfo);
sourceSize = 0;
}
@@ -305,4 +310,5 @@ primJPEGReadHeaderfromByteArraysizeerrorMgrReadHeader(
jpeg_mem_src(pcinfo, source, sourceSize);
jpeg_read_header(pcinfo, TRUE);
}
+ free(pjerr->setjmp_buffer);
}

0 comments on commit 9ffa643

Please sign in to comment.