Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion optimize.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ bool optimize_compress_PTR(INSTRUCTIONS *instructions, int *position, CODE *code
bool optimize_clear_loop(INSTRUCTIONS *instructions, int *position, CODE *code) {
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?

return false;

char clearLoop[] = "[-]";
int i;
for (i = 0; i < sizeof(clearLoop) - 1; i++) {
Expand Down