Skip to content

Conversation

@rwhitworth
Copy link
Contributor

Helps avoid #7

@rwhitworth rwhitworth mentioned this pull request Jul 8, 2017
@julianneswinoga
Copy link
Owner

In what situation does the original code cause an error?

@rwhitworth
Copy link
Contributor Author

Example input: input.gz

It fixes this error as reported by valgrind:

==943710== Invalid read of size 1
==943710==    at 0x405722: optimize_clear_loop (optimize.c:77)
==943710==    by 0x401AA1: main (yabfc.c:136)
==943710==  Address 0x56df9b8 is 0 bytes after a block of size 8 alloc'd
==943710==    at 0x4C2DDCF: realloc (vg_replace_malloc.c:785)
==943710==    by 0x4018E1: main (yabfc.c:118)

if (globalOptions.optimize < 2) // Only do on optimization level 2 and higher
return false;

if (instructions->size - (*position) < 3)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change the 3 to be based on the number of characters being checked? I.e. sizeof(clearLoop) - 1?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants