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.ortho.photo: Fix Resource Leak in find_init.c #4388

Merged
merged 13 commits into from
Oct 12, 2024
17 changes: 12 additions & 5 deletions imagery/i.ortho.photo/lib/find_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,21 @@
**************************************************************/
#include <grass/gis.h>

#define ELEMENT_BUFFER_SIZE 80

int I_find_initial(char *group)
{
char *element;
int file_exists;

element = (char *)G_malloc(80 * sizeof(char));

if (group == NULL || *group == 0)
if (group == NULL || *group == 0) {
return 0;
sprintf(element, "group/%s", group);
return G_find_file(element, "INIT_EXP", G_mapset()) != NULL;
}
ShubhamDesai marked this conversation as resolved.
Show resolved Hide resolved

element = (char *)G_malloc(ELEMENT_BUFFER_SIZE * sizeof(char));
ShubhamDesai marked this conversation as resolved.
Show resolved Hide resolved

snprintf(element, ELEMENT_BUFFER_SIZE, "group/%s", group);
file_exists = G_find_file(element, "INIT_EXP", G_mapset()) != NULL;
G_free(element);
return file_exists;
}
Loading