Memory access fixes

This commit is contained in:
Michał Janiszewski 2015-09-12 00:16:05 +02:00
parent 27ea266de1
commit 788e988992
4 changed files with 236 additions and 218 deletions

View File

@ -4870,7 +4870,9 @@ static void peep_update_thoughts(rct_peep* peep){
peep->window_invalidate_flags |= PEEP_INVALIDATE_PEEP_THOUGHTS;
// Clear top thought, push others up
if (i < PEEP_MAX_THOUGHTS - 1) {
memmove(&peep->thoughts[i], &peep->thoughts[i + 1], sizeof(rct_peep_thought)*(PEEP_MAX_THOUGHTS - i - 1));
}
peep->thoughts[PEEP_MAX_THOUGHTS - 1].type = PEEP_THOUGHT_TYPE_NONE;
}
}
@ -5891,7 +5893,9 @@ void peep_insert_new_thought(rct_peep *peep, uint8 thought_type, uint8 thought_a
// If the thought type has not changed then we need to move
// it to the top of the thought list. This is done by first removing the
// existing thought and placing it at the top.
if (i < PEEP_MAX_THOUGHTS - 1) {
memmove(thought, thought + 1, sizeof(rct_peep_thought)*(PEEP_MAX_THOUGHTS - i - 1));
}
break;
}
}
@ -5936,7 +5940,10 @@ static void peep_stop_purchase_thought(rct_peep* peep, uint8 ride_type){
if (thought->type != thought_type)continue;
if (i < PEEP_MAX_THOUGHTS - 1) {
memmove(thought, thought + 1, sizeof(rct_peep_thought)*(PEEP_MAX_THOUGHTS - i - 1));
}
peep->thoughts[PEEP_MAX_THOUGHTS - 1].type = PEEP_THOUGHT_TYPE_NONE;

View File

@ -431,7 +431,10 @@ void track_load_list(ride_list_item item)
int enumFileHandle = platform_enumerate_files_begin(RCT2_ADDRESS(RCT2_ADDRESS_TRACKS_PATH, char));
if (enumFileHandle == INVALID_HANDLE)
{
free(new_file_pointer);
return;
}
while (platform_enumerate_files_next(enumFileHandle, &enumFileInfo)) {
if (new_file_pointer > new_track_file + 0x3FF00)break;

View File

@ -834,9 +834,16 @@ int scenario_write_available_objects(FILE *file)
// Initialise buffers
buffer = malloc(bufferLength);
dstBuffer = malloc(bufferLength + sizeof(sawyercoding_chunk_header));
if (buffer == NULL || dstBuffer == NULL)
if (buffer == NULL) {
log_error("out of memory");
return 0;
}
dstBuffer = malloc(bufferLength + sizeof(sawyercoding_chunk_header));
if (dstBuffer == NULL) {
free(buffer);
log_error("out of memory");
return 0;
}
// Write entries
rct_object_entry_extended *srcEntry = (rct_object_entry_extended*)0x00F3F03C;

View File

@ -624,6 +624,7 @@ static uint8 *title_script_load()
*scriptPtr++ = atoi(part1) & 0xFF;
} else {
log_error("unknown token, %s", token);
free(binaryScript);
return NULL;
}
}