BaseTools/ImageTool: Fix PeScan error handling

This commit is contained in:
Marvin Häuser 2023-04-01 18:08:53 +02:00
parent d5eecc2e2d
commit b1851ef38d
2 changed files with 4 additions and 1 deletions

View File

@ -107,7 +107,6 @@ PeXip (
Pe = NULL; Pe = NULL;
if (!Result) { if (!Result) {
ToolImageDestruct (&Image);
return RETURN_ABORTED; return RETURN_ABORTED;
} }

View File

@ -450,6 +450,7 @@ ToolContextConstructPe (
Result = ScanPeGetHeaderInfo (&Image->HeaderInfo, &Context, ModuleType); Result = ScanPeGetHeaderInfo (&Image->HeaderInfo, &Context, ModuleType);
if (!Result) { if (!Result) {
fprintf (stderr, "ImageTool: Could not retrieve header info\n"); fprintf (stderr, "ImageTool: Could not retrieve header info\n");
ToolImageDestruct (Image);
FreeAlignedPages (Destination, DestinationPages); FreeAlignedPages (Destination, DestinationPages);
return false; return false;
} }
@ -457,6 +458,7 @@ ToolContextConstructPe (
Result = ScanPeGetDebugInfo (&Image->DebugInfo, &Context); Result = ScanPeGetDebugInfo (&Image->DebugInfo, &Context);
if (!Result) { if (!Result) {
fprintf (stderr, "ImageTool: Could not retrieve debug info\n"); fprintf (stderr, "ImageTool: Could not retrieve debug info\n");
ToolImageDestruct (Image);
FreeAlignedPages (Destination, DestinationPages); FreeAlignedPages (Destination, DestinationPages);
return false; return false;
} }
@ -464,6 +466,7 @@ ToolContextConstructPe (
Result = ScanPeGetSegmentInfo (&Image->SegmentInfo, &Image->HiiInfo, &Context); Result = ScanPeGetSegmentInfo (&Image->SegmentInfo, &Image->HiiInfo, &Context);
if (!Result) { if (!Result) {
fprintf (stderr, "ImageTool: Could not retrieve segment info\n"); fprintf (stderr, "ImageTool: Could not retrieve segment info\n");
ToolImageDestruct (Image);
FreeAlignedPages (Destination, DestinationPages); FreeAlignedPages (Destination, DestinationPages);
return false; return false;
} }
@ -471,6 +474,7 @@ ToolContextConstructPe (
Result = ScanPeGetRelocInfo (&Image->RelocInfo, &Context); Result = ScanPeGetRelocInfo (&Image->RelocInfo, &Context);
if (!Result) { if (!Result) {
fprintf (stderr, "ImageTool: Could not retrieve reloc info\n"); fprintf (stderr, "ImageTool: Could not retrieve reloc info\n");
ToolImageDestruct (Image);
} }
FreeAlignedPages (Destination, DestinationPages); FreeAlignedPages (Destination, DestinationPages);