Fix leaks of input source lists and bounding boxes

This commit is contained in:
Eric Fischer
2016-04-27 10:45:25 -07:00
parent 0205086886
commit 6a37ea4e54
+5 -6
View File
@@ -103,7 +103,7 @@ struct reader {
long long geompos; long long geompos;
long long indexpos; long long indexpos;
long long *file_bbox; long long file_bbox[4];
struct stat geomst; struct stat geomst;
struct stat metast; struct stat metast;
@@ -1660,11 +1660,6 @@ int read_json(int argc, struct source **sourcelist, char *fname, const char *lay
// Keep metadata file from being completely empty if no attributes // Keep metadata file from being completely empty if no attributes
serialize_int(r->metafile, 0, &r->metapos, "meta"); serialize_int(r->metafile, 0, &r->metapos, "meta");
r->file_bbox = malloc(4 * sizeof(long long));
if (r->file_bbox == NULL) {
perror("Out of memory");
exit(EXIT_FAILURE);
}
r->file_bbox[0] = r->file_bbox[1] = UINT_MAX; r->file_bbox[0] = r->file_bbox[1] = UINT_MAX;
r->file_bbox[2] = r->file_bbox[3] = 0; r->file_bbox[2] = r->file_bbox[3] = 0;
} }
@@ -2844,5 +2839,9 @@ int main(int argc, char **argv) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
for (i = 0; i < nsources; i++) {
free(sourcelist[i]);
}
return ret; return ret;
} }