jasper-software / jasper

Official Repository for the JasPer Image Coding Toolkit
http://www.ece.uvic.ca/~mdadams/jasper
Other
223 stars 101 forks source link

Problems with source code in Visual Studio #371

Closed SebastianoGuer closed 8 months ago

SebastianoGuer commented 8 months ago

In source jas_icc.c, function jas_icclut8_output the statements: lut8->clut = 0; lut8->intabsbuf = 0; lut8->outtabsbuf = 0; always provoke memory violation in the following statements: if (jas_iccputuint8(out, lut8->intabsbuf[i])) { if (jas_iccputuint8(out, lut8->outtabsbuf[i])) { if (jas_iccputuint8(out, lut8->clut[i])) {

In source jas_image.c the following is missing:

ifdef _MSC_VER

include

endif

Then, after _alloca (two times present; but _malloca should not be better?), the pointer not null test is missing: if (!stack_buffer) return -1;

In source jpc_t1enc.c, macro refpass_step (d) = (dp); \ --> confusion: d is not a macro argument, but a variable declared outside the macro: d = (dp); \

mdadams commented 8 months ago

@SebastianoGuer Concerning the last issue you raised, I fixed the refpass_step macro. Although it seems that there was no incorrect code behavior, I agree that the code was quite confusing as it was written. As for the first issue, I cannot address it without more information from you. Please open a new GitHub issue for this specific problem with a reproducer that causes a failure. As for the second issue involving alloca, this is not a bug. alloca cannot return null. An allocation failure results in a stack overflow crash. Since alloca is only used to workaround bugs in the MSVC compiler, it would be better for Microsoft to fix their compiler instead of adding more uglyness to the JasPer code.