From 39fa0239ba33f3f2effb1e6911d56dde6cad5983 Mon Sep 17 00:00:00 2001 From: integerbang Date: Wed, 12 Apr 2023 22:07:45 -0400 Subject: [PATCH] saturn_bind_texture: Return pointers to literals directly instead of constructing string classes from them The saturn_bind_texture function constructed a string from the contents of a literal and then returned a pointer to its data if the texture to replace is either one of the playable character's textures or the background of the Secret Aquarium. Doing this isn't a good idea since the string's destructor will get called once it goes out of scope, freeing the data it returns. The pointer to any of the string literals really should've been returned instead from the start, but since that wasn't the case, this commit fixes that problem. --- src/saturn/saturn_textures.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/saturn/saturn_textures.cpp b/src/saturn/saturn_textures.cpp index 4ba3117d..ab9c7f9b 100644 --- a/src/saturn/saturn_textures.cpp +++ b/src/saturn/saturn_textures.cpp @@ -182,19 +182,13 @@ const void* saturn_bind_texture(const void* input) { } if (show_vmario_emblem) { - if (texName == "actors/mario/no_m.rgba16") { - outputTexture = string("actors/mario/mario_logo.rgba16").c_str(); - const void* output = static_cast(outputTexture); - return output; - } + if (texName == "actors/mario/no_m.rgba16") + return "actors/mario/mario_logo.rgba16"; } if (gCurrLevelNum == LEVEL_SA && use_color_background) { - if (texName.find("textures/skybox_tiles/") != string::npos) { - outputTexture = string("textures/saturn/white.rgba16").c_str(); - const void* output = static_cast(outputTexture); - return output; - } + if (texName.find("textures/skybox_tiles/") != string::npos) + return "textures/saturn/white.rgba16"; } return input;