guimenu.cpp: Avoid fixed-length buffer for path

There is no actual reason why the path length ought to be limited to
1024 bytes. Since strPath was already a std::string, it made sense to
use to concatenate all tokens with it and use c_str instead.


git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@9486 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: 1ffcb2a1e6b949ce31ddc3466921997b38855f44
Former-commit-id: 1a0565184bdc86ad5c7fd10f1db29b08ae000953
This commit is contained in:
xavi92 2024-07-15 03:05:28 +00:00
parent fd80f2335a
commit 73dd7a7d49

View file

@ -29,6 +29,7 @@
#include <cstdlib>
#include <string>
#include <map>
#include <iostream>
#include <portability.h>
@ -989,13 +990,21 @@ GfuiMenuCreateStaticControls(void* hscr, void* hparm)
void*
GfuiMenuLoad(const char* pszMenuPath)
{
std::string strPath("data/menu/");
const char *data = GfDataDir();
if (!data)
{
std::cerr << "GfDataDir failed" << std::endl;
return NULL;
}
std::string strPath;
strPath += data;
strPath += "data/menu/";
strPath += pszMenuPath;
char buf[1024];
snprintf(buf, sizeof(buf), "%s%s", GfDataDir(), strPath.c_str());
return GfParmReadFile(buf, GFPARM_RMODE_STD);
return GfParmReadFile(strPath.c_str(), GFPARM_RMODE_STD);
}
tdble