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

i.pca: Fix Resource Leak issue #4664

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 2 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
9 changes: 8 additions & 1 deletion imagery/i.pca/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,13 @@ static int calc_mu_cov(int *fds, double **covar, double *mu, double *stddev,
}
G_percent(1, 1, 1);

if (count < 2)
if (count < 2) {
G_free(sum2);
G_free(sd);
G_free(sumsq);
G_free(rowbuf);
return 0;
}

for (i = 0; i < bands; i++) {
if (stddev) {
Expand Down Expand Up @@ -571,6 +576,8 @@ static int write_pca(double **eigmat, double *mu, double *stddev, int *inp_fd,
G_free(min);
G_free(max);
G_free(old_range);
G_free(pcs);
G_free(out_fd);

return 0;
}
Expand Down
Loading