diff --git a/src/r_data.c b/src/r_data.c index 0aba42750..3a7fb602e 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -625,11 +625,11 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture) char *texturesToken; UINT8 texturesTokenLength; char *endPos; - char *newTextureName = NULL; INT32 newTextureWidth; INT32 newTextureHeight; texture_t *resultTexture = NULL; texpatch_t *newPatch; + char newTextureName[9]; // no longer dynamically allocated // Texture name texturesToken = M_GetToken(NULL); @@ -644,13 +644,10 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture) } else { - if (newTextureName != NULL) - { - Z_Free(newTextureName); - } - newTextureName = (char *)Z_Malloc((texturesTokenLength+1)*sizeof(char),PU_STATIC,NULL); - M_Memcpy(newTextureName,texturesToken,texturesTokenLength*sizeof(char)); - newTextureName[texturesTokenLength] = '\0'; + memset(&newTextureName, 0, 9); + M_Memcpy(newTextureName, texturesToken, texturesTokenLength); + // ^^ we've confirmed that the token is <= 8 characters so it will never overflow a 9 byte char buffer + strupr(newTextureName); // Just do this now so we don't have to worry about it } Z_Free(texturesToken); @@ -734,7 +731,6 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture) { // Allocate memory for a zero-patch texture. Obviously, we'll be adding patches momentarily. resultTexture = (texture_t *)Z_Calloc(sizeof(texture_t),PU_STATIC,NULL); - strupr(newTextureName); M_Memcpy(resultTexture->name, newTextureName, 8); resultTexture->width = newTextureWidth; resultTexture->height = newTextureHeight; @@ -790,7 +786,6 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture) } Z_Free(texturesToken); - Z_Free(newTextureName); // Can't BELIEVE I forgot to free this before ._.; if (actuallyLoadTexture) return resultTexture; else return NULL; } diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 0f9fa58a8..8d345d2a8 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1696,9 +1696,14 @@ void I_StartupGraphics(void) } #endif { - char vd[100]; //stack space for video name - //CONS_Printf(M_GetText("Starting up with video driver : %s\n"), SDL_VideoDriverName(vd,100)); - if (strncasecmp(vd, "gcvideo", 8) == 0 || strncasecmp(vd, "fbcon", 6) == 0 || strncasecmp(vd, "wii", 4) == 0 || strncasecmp(vd, "psl1ght", 8) == 0) + const char *vd = SDL_GetCurrentVideoDriver(); + //CONS_Printf(M_GetText("Starting up with video driver: %s\n"), vd); + if (vd && ( + strncasecmp(vd, "gcvideo", 8) == 0 || + strncasecmp(vd, "fbcon", 6) == 0 || + strncasecmp(vd, "wii", 4) == 0 || + strncasecmp(vd, "psl1ght", 8) == 0 + )) framebuffer = SDL_TRUE; } if (M_CheckParm("-software"))