Closed memory leak with error in iso_file_make_md5(). Coverity CID 12573.

This commit is contained in:
Thomas Schmitt 2015-10-09 20:35:15 +02:00
parent 48453ef1da
commit 78d2c02ad8

View File

@ -3047,21 +3047,23 @@ int iso_file_make_md5(IsoFile *file, int flag)
if (file->from_old_session) if (file->from_old_session)
dig = 1; dig = 1;
md5 = calloc(16, 1); md5 = calloc(16, 1);
if (md5 == NULL)
return ISO_OUT_OF_MEM;
ret = iso_stream_make_md5(file->stream, md5, dig); ret = iso_stream_make_md5(file->stream, md5, dig);
if (ret < 0) if (ret < 0) {
goto ex; free(md5);
return ret;
}
iso_node_remove_xinfo((IsoNode *) file, checksum_md5_xinfo_func); iso_node_remove_xinfo((IsoNode *) file, checksum_md5_xinfo_func);
ret = iso_node_add_xinfo((IsoNode *) file, checksum_md5_xinfo_func, md5); ret = iso_node_add_xinfo((IsoNode *) file, checksum_md5_xinfo_func, md5);
if (ret == 0) if (ret == 0)
ret = ISO_ERROR; /* should not happen after iso_node_remove_xinfo() */ ret = ISO_ERROR; /* should not happen after iso_node_remove_xinfo() */
if (ret < 0) { if (ret < 0) {
free(md5); free(md5);
goto ex;
}
ret = 1;
ex:;
return ret; return ret;
} }
return 1;
}