mindtct: Fix memory leak in error path in gen_image_maps()

Free the maps if we're not returning them.

libfprint/nbis/mindtct/maps.c:176:14: warning: Potential leak of memory pointed to by 'direction_map'
      return(ret);
             ^~~
libfprint/nbis/mindtct/maps.c:195:14: warning: Potential leak of memory pointed to by 'low_contrast_map'
      return(ret);
             ^~~
libfprint/nbis/mindtct/maps.c:195:14: warning: Potential leak of memory pointed to by 'low_flow_map'
      return(ret);
             ^~~
This commit is contained in:
Bastien Nocera 2018-12-13 11:30:06 +01:00
parent c3e996b96c
commit a53f07a8f6

View file

@ -159,6 +159,9 @@ int gen_image_maps(int **odmap, int **olcmap, int **olfmap, int **ohcmap,
} }
if((ret = morph_TF_map(low_flow_map, mw, mh, lfsparms))){ if((ret = morph_TF_map(low_flow_map, mw, mh, lfsparms))){
free(direction_map);
free(low_contrast_map);
free(low_flow_map);
return(ret); return(ret);
} }
@ -173,6 +176,9 @@ int gen_image_maps(int **odmap, int **olcmap, int **olfmap, int **ohcmap,
/* 5. Interpolate INVALID direction blocks with their valid neighbors. */ /* 5. Interpolate INVALID direction blocks with their valid neighbors. */
if((ret = interpolate_direction_map(direction_map, low_contrast_map, if((ret = interpolate_direction_map(direction_map, low_contrast_map,
mw, mh, lfsparms))){ mw, mh, lfsparms))){
free(direction_map);
free(low_contrast_map);
free(low_flow_map);
return(ret); return(ret);
} }
@ -192,6 +198,9 @@ int gen_image_maps(int **odmap, int **olcmap, int **olfmap, int **ohcmap,
/* 9. Generate High Curvature Map from interpolated Direction Map. */ /* 9. Generate High Curvature Map from interpolated Direction Map. */
if((ret = gen_high_curve_map(&high_curve_map, direction_map, mw, mh, if((ret = gen_high_curve_map(&high_curve_map, direction_map, mw, mh,
lfsparms))){ lfsparms))){
free(direction_map);
free(low_contrast_map);
free(low_flow_map);
return(ret); return(ret);
} }