mirror of https://github.com/OpenRCT2/OpenRCT2.git
Free after malloc
This commit is contained in:
parent
807c5fcb4b
commit
13b32e8044
|
@ -321,23 +321,29 @@ static void printImageId(uint32 input, utf8string *out) {
|
|||
uint32 image = input & 0x7FFFF;
|
||||
uint32 palette = input & ~0x7FFFF;
|
||||
|
||||
bool allocated = false;
|
||||
utf8string paletteName;
|
||||
if (palette == PALETTE_98)paletteName = "PALETTE_98";
|
||||
else if (palette == PALETTE_9C)paletteName = "PALETTE_9C";
|
||||
else if (palette == PALETTE_A0)paletteName = "PALETTE_A0";
|
||||
else if (palette == PALETTE_A4)paletteName = "PALETTE_A4";
|
||||
else {
|
||||
allocated = true;
|
||||
paletteName = malloc(16);
|
||||
sprintf(paletteName, "0x%08X", palette);
|
||||
}
|
||||
|
||||
if (image == 0) {
|
||||
sprintf(*out, "%s", paletteName);
|
||||
} else if(image & 0x70000) {
|
||||
} else if (image & 0x70000) {
|
||||
sprintf(*out, "%s | vehicle.base_image_id + %d", paletteName, image & ~0x70000);
|
||||
} else {
|
||||
sprintf(*out, "%s | %d", paletteName, image);
|
||||
}
|
||||
|
||||
if (allocated) {
|
||||
free(paletteName);
|
||||
}
|
||||
}
|
||||
|
||||
static void printFunctionCall(utf8string *out, function_call call) {
|
||||
|
@ -405,6 +411,7 @@ static void printFunctionCallArray(utf8string *out, function_call calls[], uint8
|
|||
utf8string callOut = malloc(128);
|
||||
printFunctionCall(&callOut, calls[i]);
|
||||
sprintf(*out + strlen(*out), "%s\n", callOut);
|
||||
free(callOut);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -514,6 +521,8 @@ bool testTrackElement(uint8 rideType, uint8 trackType, utf8string *error) {
|
|||
sprintf(diff + strlen(diff), ">>> ACTUAL\n");
|
||||
sprintf(*error, "Call counts don't match (was %d, expected %d) [direction:%d trackSequence:%d]", newCallCount, oldCallCount, direction, trackSequence);
|
||||
sprintf(*error + strlen(*error), "\n%s", diff);
|
||||
|
||||
free(diff);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -553,6 +562,7 @@ void testRide(int rideType) {
|
|||
if (!success) {
|
||||
printf(" FAILED!\n %s", error);
|
||||
}
|
||||
free(error);
|
||||
printf(ANSI_COLOR_RESET "\n");
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue