mirror of
https://github.com/aaru-dps/libaaruformat.git
synced 2025-12-16 19:24:40 +00:00
Set to NULL all pointers inside context when closing to know none is forgotten.
This commit is contained in:
42
src/close.c
42
src/close.c
@@ -46,14 +46,24 @@ int aaruf_close(void* context)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This may do nothing if imageStream is NULL, but as the behaviour is undefined, better sure than sorry
|
// This may do nothing if imageStream is NULL, but as the behaviour is undefined, better sure than sorry
|
||||||
if(ctx->imageStream != NULL) fclose(ctx->imageStream);
|
if(ctx->imageStream != NULL)
|
||||||
|
{
|
||||||
|
fclose(ctx->imageStream);
|
||||||
|
ctx->imageStream = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
free(ctx->sectorPrefix);
|
free(ctx->sectorPrefix);
|
||||||
|
ctx->sectorPrefix = NULL;
|
||||||
free(ctx->sectorPrefixCorrected);
|
free(ctx->sectorPrefixCorrected);
|
||||||
|
ctx->sectorPrefixCorrected = NULL;
|
||||||
free(ctx->sectorSuffix);
|
free(ctx->sectorSuffix);
|
||||||
|
ctx->sectorSuffix = NULL;
|
||||||
free(ctx->sectorSuffixCorrected);
|
free(ctx->sectorSuffixCorrected);
|
||||||
|
ctx->sectorSuffixCorrected = NULL;
|
||||||
free(ctx->sectorSubchannel);
|
free(ctx->sectorSubchannel);
|
||||||
|
ctx->sectorSubchannel = NULL;
|
||||||
free(ctx->mode2Subheaders);
|
free(ctx->mode2Subheaders);
|
||||||
|
ctx->mode2Subheaders = NULL;
|
||||||
|
|
||||||
if(ctx->mediaTagsTail != NULL)
|
if(ctx->mediaTagsTail != NULL)
|
||||||
{
|
{
|
||||||
@@ -62,45 +72,73 @@ int aaruf_close(void* context)
|
|||||||
while(mediaTag->previous != NULL)
|
while(mediaTag->previous != NULL)
|
||||||
{
|
{
|
||||||
free(mediaTag->data);
|
free(mediaTag->data);
|
||||||
|
mediaTag->data = NULL;
|
||||||
mediaTag = mediaTag->previous;
|
mediaTag = mediaTag->previous;
|
||||||
free(mediaTag->next);
|
free(mediaTag->next);
|
||||||
|
mediaTag->next = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctx->mediaTagsTail = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ctx->mediaTagsHead != NULL)
|
if(ctx->mediaTagsHead != NULL)
|
||||||
{
|
{
|
||||||
free(ctx->mediaTagsHead->data);
|
free(ctx->mediaTagsHead->data);
|
||||||
|
ctx->mediaTagsHead->data = NULL;
|
||||||
free(ctx->mediaTagsHead);
|
free(ctx->mediaTagsHead);
|
||||||
|
ctx->mediaTagsHead = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __linux__ // TODO: Implement
|
#ifdef __linux__ // TODO: Implement
|
||||||
if(!ctx->inMemoryDdt) { munmap(ctx->userDataDdt, ctx->mappedMemoryDdtSize); }
|
if(!ctx->inMemoryDdt)
|
||||||
|
{
|
||||||
|
munmap(ctx->userDataDdt, ctx->mappedMemoryDdtSize);
|
||||||
|
ctx->userDataDdt = NULL;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
free(ctx->sectorPrefixDdt);
|
free(ctx->sectorPrefixDdt);
|
||||||
|
ctx->sectorPrefixDdt = NULL;
|
||||||
free(ctx->sectorSuffixDdt);
|
free(ctx->sectorSuffixDdt);
|
||||||
|
ctx->sectorSuffixDdt = NULL;
|
||||||
|
|
||||||
free(ctx->metadataBlock);
|
free(ctx->metadataBlock);
|
||||||
|
ctx->metadataBlock = NULL;
|
||||||
free(ctx->trackEntries);
|
free(ctx->trackEntries);
|
||||||
|
ctx->trackEntries = NULL;
|
||||||
free(ctx->cicmBlock);
|
free(ctx->cicmBlock);
|
||||||
|
ctx->cicmBlock = NULL;
|
||||||
|
|
||||||
if(ctx->dumpHardwareEntriesWithData != NULL)
|
if(ctx->dumpHardwareEntriesWithData != NULL)
|
||||||
{
|
{
|
||||||
for(i = 0; i < ctx->dumpHardwareHeader.entries; i++)
|
for(i = 0; i < ctx->dumpHardwareHeader.entries; i++)
|
||||||
{
|
{
|
||||||
free(ctx->dumpHardwareEntriesWithData[i].extents);
|
free(ctx->dumpHardwareEntriesWithData[i].extents);
|
||||||
|
ctx->dumpHardwareEntriesWithData[i].extents = NULL;
|
||||||
free(ctx->dumpHardwareEntriesWithData[i].manufacturer);
|
free(ctx->dumpHardwareEntriesWithData[i].manufacturer);
|
||||||
|
ctx->dumpHardwareEntriesWithData[i].manufacturer = NULL;
|
||||||
free(ctx->dumpHardwareEntriesWithData[i].model);
|
free(ctx->dumpHardwareEntriesWithData[i].model);
|
||||||
|
ctx->dumpHardwareEntriesWithData[i].model = NULL;
|
||||||
free(ctx->dumpHardwareEntriesWithData[i].revision);
|
free(ctx->dumpHardwareEntriesWithData[i].revision);
|
||||||
|
ctx->dumpHardwareEntriesWithData[i].revision = NULL;
|
||||||
free(ctx->dumpHardwareEntriesWithData[i].firmware);
|
free(ctx->dumpHardwareEntriesWithData[i].firmware);
|
||||||
|
ctx->dumpHardwareEntriesWithData[i].firmware = NULL;
|
||||||
free(ctx->dumpHardwareEntriesWithData[i].serial);
|
free(ctx->dumpHardwareEntriesWithData[i].serial);
|
||||||
|
ctx->dumpHardwareEntriesWithData[i].serial = NULL;
|
||||||
free(ctx->dumpHardwareEntriesWithData[i].softwareName);
|
free(ctx->dumpHardwareEntriesWithData[i].softwareName);
|
||||||
|
ctx->dumpHardwareEntriesWithData[i].softwareName = NULL;
|
||||||
free(ctx->dumpHardwareEntriesWithData[i].softwareVersion);
|
free(ctx->dumpHardwareEntriesWithData[i].softwareVersion);
|
||||||
|
ctx->dumpHardwareEntriesWithData[i].softwareVersion = NULL;
|
||||||
free(ctx->dumpHardwareEntriesWithData[i].softwareOperatingSystem);
|
free(ctx->dumpHardwareEntriesWithData[i].softwareOperatingSystem);
|
||||||
|
ctx->dumpHardwareEntriesWithData[i].softwareOperatingSystem = NULL;
|
||||||
}
|
}
|
||||||
|
ctx->dumpHardwareEntriesWithData = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(ctx->readableSectorTags);
|
free(ctx->readableSectorTags);
|
||||||
|
ctx->readableSectorTags = NULL;
|
||||||
|
|
||||||
|
// TODO: Free caches
|
||||||
|
|
||||||
free(context);
|
free(context);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user