-
-
Notifications
You must be signed in to change notification settings - Fork 309
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
i.pca: Fix Resource Leak issue #4664
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm not misreading the code, sum2
and rowbuf
are both 2D arrays, of which each part also needs to be freed.
This will lead to too much repetitive code for freeing resources, so I'd suggest we use goto with a return value variable.
Done |
} | ||
for (i = 0; i < bands; i++) | ||
mu[i] = sum[i] / count; | ||
|
||
cleanup: | ||
for (i = 0; i < bands; i++) { | ||
if (sum2[i]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to check for NULL before free.
Also, I'd prefer a more descriptive goto label name (free_exit
, comes to my mind, but you may have another suggestion).
This pull request fixes issue identified by coverity scan (CID : 1207830, 1207835, 1207833, 1207834, 1207836, 1207837)
G_free() is used.