Skip to content

Commit ce14ecf

Browse files
authored
lib/nviz: Fix Resource Leak issue in nviz.c (OSGeo#6354)
* Fix Resource Leak * Changes
1 parent 9946b31 commit ce14ecf

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

lib/nviz/nviz.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,15 @@ struct fringe_data *Nviz_new_fringe(nv_data *data, int id, unsigned long color,
151151
double elev, int nw, int ne, int sw, int se)
152152
{
153153
int num;
154-
int *surf;
154+
int *surf = NULL;
155155
struct fringe_data *f;
156156

157157
if (!GS_surf_exists(id)) {
158158
/* select first surface from the list */
159159
surf = GS_get_surf_list(&num);
160-
if (num < 1)
160+
if (!surf) {
161161
return NULL;
162+
}
162163
id = surf[0];
163164
G_free(surf);
164165
}
@@ -194,14 +195,15 @@ struct fringe_data *Nviz_set_fringe(nv_data *data, int id, unsigned long color,
194195
double elev, int nw, int ne, int sw, int se)
195196
{
196197
int i, num;
197-
int *surf;
198+
int *surf = NULL;
198199
struct fringe_data *f;
199200

200201
if (!GS_surf_exists(id)) {
201202
/* select first surface from the list */
202203
surf = GS_get_surf_list(&num);
203-
if (num < 1)
204+
if (!surf) {
204205
return NULL;
206+
}
205207
id = surf[0];
206208
G_free(surf);
207209
}

0 commit comments

Comments
 (0)