Solved some free bugs
This commit is contained in:
parent
70c01e6d33
commit
3279ae04a7
|
@ -335,8 +335,12 @@ static int g1m_parse_mcs_capture(g1m_mcsfile_t *handle, FILE *stream,
|
|||
DREAD(hd, mcs_captureheader)
|
||||
|
||||
/* correct endianess */
|
||||
handle->width = be16toh(hd.width);
|
||||
handle->height = be16toh(hd.height);
|
||||
hd.width = be16toh(hd.width);
|
||||
hd.height = be16toh(hd.height);
|
||||
|
||||
/* store */
|
||||
handle->width = hd.width;
|
||||
handle->height = hd.height;
|
||||
|
||||
/* print info */
|
||||
log_info("capture is %ux%u sized", hd.width, hd.height);
|
||||
|
@ -468,7 +472,7 @@ int g1m_parse_mcs(g1m_t *handle, FILE *stream, uint_fast16_t num)
|
|||
/* No "global" header for MCS parts, because this "global header"
|
||||
* was the standard header. */
|
||||
/* allocate memory for the subparts */
|
||||
handle->part_count = 0;
|
||||
handle->part_count = num;
|
||||
handle->_parts_size = num;
|
||||
handle->parts = malloc(sizeof(g1m_mcs_t*) * num);
|
||||
if (!handle->parts) return (g1m_error_alloc);
|
||||
|
@ -493,6 +497,7 @@ int g1m_parse_mcs(g1m_t *handle, FILE *stream, uint_fast16_t num)
|
|||
g1m_mcs_t *mcs = handle->parts[i];
|
||||
|
||||
/* prepare it */
|
||||
mcs->file_count = hd.subcount;
|
||||
mcs->_files_size = hd.subcount;
|
||||
mcs->files = malloc(sizeof(g1m_mcsfile_t*) * hd.subcount);
|
||||
if (!mcs->files) goto fail;
|
||||
|
|
|
@ -87,12 +87,15 @@ void g1m_free_mcsfile(g1m_mcsfile_t *handle)
|
|||
if (handle->type & (g1m_mcstype_mat | g1m_mcstype_list
|
||||
| g1m_mcstype_spreadsheet))
|
||||
free(handle->cells);
|
||||
|
||||
/* free the first image */
|
||||
if (handle->type & (g1m_mcstype_pict | g1m_mcstype_capt))
|
||||
free(handle->image);
|
||||
|
||||
/* free the second image */
|
||||
if (handle->type & g1m_mcstype_pict)
|
||||
free(handle->second_image);
|
||||
|
||||
/* free the handle */
|
||||
free(handle);
|
||||
}
|
||||
|
@ -109,7 +112,7 @@ void g1m_free(g1m_t *handle)
|
|||
if (!handle) return ;
|
||||
|
||||
/* mcs time! */
|
||||
if ((handle->type & g1m_type_mcs) && handle->parts) {
|
||||
if (handle->type & g1m_type_mcs && handle->parts) {
|
||||
g1m_mcs_t **mcs = handle->parts;
|
||||
int mcs_count = handle->part_count;
|
||||
for (int i = 0; i < mcs_count; i++) {
|
||||
|
@ -122,7 +125,10 @@ void g1m_free(g1m_t *handle)
|
|||
continue ;
|
||||
g1m_free_mcsfile(files[j]);
|
||||
}
|
||||
free(files);
|
||||
free(mcs[i]);
|
||||
}
|
||||
free(mcs);
|
||||
}
|
||||
|
||||
/* free the handle */
|
||||
|
|
Reference in New Issue