Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

your sample code is not processing the very last pixel in your png example. #97

Closed
bvdeenen opened this issue Nov 29, 2024 · 5 comments
Closed

Comments

@bvdeenen
Copy link

Hi Pedro
I was trying the Zig array out of bounds check while having built your png example and just added +2 to the buffer[index + ..] statements.
To my surprise the array bounds checker didn't trigger.
A bit of searching led me the conclusion your while loop limit is wrong. It should just be index<len. The limit is checked before the loop body is executed, the increment (index+=4) after the loop body has been executed.

Thanks for the great work!

@pedropark99
Copy link
Owner

Thank you @bvdeenen! I will take a look at it

@bvdeenen
Copy link
Author

Thank you @bvdeenen! I will take a look at it

I just checked to make sure, and I'm right:

    var index: u32 = 0;
    const len = 12;
    while (index < len - 4) : (index += 4) {
        try stdout.print("index={},  ", .{index});
    }

This prints 0 and 4, whereas the last one should be 8.

@pedropark99
Copy link
Owner

Solved by #98

@bvdeenen
Copy link
Author

bvdeenen commented Dec 5, 2024

I'm pretty sure the issue still exists after the merge. Probably forgotten in the refactor. @pedropark99

@pedropark99
Copy link
Owner

Thanks, fixed.

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

No branches or pull requests

2 participants