@@ -145,6 +145,7 @@ int Vect_set_varray_from_cat_list(struct Map_info *Map, int field,
145
145
146
146
if (n > varray -> size ) { /* not enough space */
147
147
G_warning (_ ("Not enough space in vector array" ));
148
+ Vect_destroy_cats_struct (Cats );
148
149
return 0 ;
149
150
}
150
151
@@ -168,6 +169,7 @@ int Vect_set_varray_from_cat_list(struct Map_info *Map, int field,
168
169
169
170
if (n > varray -> size ) { /* not enough space */
170
171
G_warning (_ ("Not enough space in vector array" ));
172
+ Vect_destroy_cats_struct (Cats );
171
173
return 0 ;
172
174
}
173
175
@@ -261,8 +263,6 @@ int Vect_set_varray_from_db(struct Map_info *Map, int field, const char *where,
261
263
return 0 ;
262
264
}
263
265
264
- Cats = Vect_new_cats_struct ();
265
-
266
266
/* Select categories from DB to array */
267
267
Fi = Vect_get_field (Map , field );
268
268
if (Fi == NULL ) {
@@ -274,6 +274,7 @@ int Vect_set_varray_from_db(struct Map_info *Map, int field, const char *where,
274
274
if (driver == NULL ) {
275
275
G_warning (_ ("Unable to open database <%s> by driver <%s>" ),
276
276
Fi -> database , Fi -> driver );
277
+ Vect_destroy_field_info (Fi );
277
278
return -1 ;
278
279
}
279
280
@@ -285,8 +286,11 @@ int Vect_set_varray_from_db(struct Map_info *Map, int field, const char *where,
285
286
G_warning (
286
287
_ ("Unable to select record from table <%s> (key %s, where %s)" ),
287
288
Fi -> table , Fi -> key , where );
289
+ Vect_destroy_field_info (Fi );
288
290
return -1 ;
289
291
}
292
+ Vect_destroy_field_info (Fi );
293
+ Cats = Vect_new_cats_struct ();
290
294
291
295
if (type & GV_AREA ) { /* Areas */
292
296
n = Vect_get_num_areas (Map );
@@ -297,6 +301,8 @@ int Vect_set_varray_from_db(struct Map_info *Map, int field, const char *where,
297
301
it for all features. */
298
302
if (n > varray -> size ) { /* not enough space */
299
303
G_warning (_ ("Not enough space in vector array" ));
304
+ Vect_destroy_cats_struct (Cats );
305
+ G_free (cats );
300
306
return 0 ;
301
307
}
302
308
@@ -329,6 +335,8 @@ int Vect_set_varray_from_db(struct Map_info *Map, int field, const char *where,
329
335
330
336
if (n > varray -> size ) { /* not enough space */
331
337
G_warning (_ ("Not enough space in vector array" ));
338
+ Vect_destroy_cats_struct (Cats );
339
+ G_free (cats );
332
340
return 0 ;
333
341
}
334
342
0 commit comments