fhanau / Efficient-Compression-Tool

Fast and effective C++ file optimizer
Apache License 2.0
596 stars 41 forks source link

Access violation in merge.h in windows release build only #129

Open jstavats opened 1 year ago

jstavats commented 1 year ago

Hi, I've got some png images here that repeatably crash a windows release build of ECT, but are processed fine by a debug build. They crash at line 83 of merge.h in zopfli at the while statement:

/ The remaining few bytes. / while (scan != end && scan == match) { scan++; match++; }

I've been able to see that periodically the variable scan is equal to end+1 at the first call of the GetMatch function, and so the access violation occurs when it goes to access then memory at scan. I changed the above lines to:

while (scan < end && scan == match) { scan++; match++; }

which seems to make the problem go away, but without knowing what the issue is, I cannot say whether this is a safe patch.

Any thoughts?

Jay

fhanau commented 1 year ago

Sounds like something to be investigated – can you attach an image where the problem occurs?