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

Fix memory leak in _zbar_sq_decode #294

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

arcz
Copy link

@arcz arcz commented Aug 26, 2024

This patch fixes two error paths where _zbar_sq_decode returns without executing the free_borders cleanup code and leaks memory.

@@ -371,7 +371,7 @@ found_start:;
border_len = 1;
top_border = malloc(sizeof(sq_point));
if (!top_border)
return 1;
goto free_borders;
Copy link

Choose a reason for hiding this comment

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

I think there is no leak because the top border is the first one that would be allocated. Skipping free_borders is a matter of speed.

@@ -471,7 +471,7 @@ found_start:;
}
}
if (cur_len != border_len || border_len < 6)
return 1;
goto free_borders;
Copy link

Choose a reason for hiding this comment

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

It seems there is a leak. This change looks fine.

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