Skip to content

Commit

Permalink
refs ignore SNESAPU.DLL
Browse files Browse the repository at this point in the history
* Script700 の追加読み込み時のバッファサイズ計算を追加
  • Loading branch information
dgrfactory committed Feb 4, 2025
1 parent cc73d4a commit d5cd2ae
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions snesapu.dll/thirdparty/SNESAPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ void IncludeScript700File(u32 addr, u32 value, void *lpData) {

if (_700Asc) {
// get buffer size
if (_700DirSize + value > 2048) {
if (_700DirSize + value >= 2048) {
FreeLibrary(hModule);
free(lp700File);
return;
Expand All @@ -300,8 +300,16 @@ void IncludeScript700File(u32 addr, u32 value, void *lpData) {
LoadScript700(func, lp700File, addr);
} else {
// get buffer size
u32 cchWideChar = MultiByteToWideChar(CP_ACP, NULL, (LPCSTR)lpData, -1, NULL, NULL);
if (_700DirSize + cchWideChar + cchWideChar + 2 >= 2048) {
FreeLibrary(hModule);
free(lp700File);
return;
}

// ansi to wide char
void *lpFile = (void*)((u32)lp700File + _700DirSize);
u32 result = MultiByteToWideChar(CP_ACP, NULL, (LPCSTR)lpData, -1, (LPWSTR)lpFile, 2048 - _700DirSize);
u32 result = MultiByteToWideChar(CP_ACP, NULL, (LPCSTR)lpData, -1, (LPWSTR)lpFile, cchWideChar);
if (!result) {
FreeLibrary(hModule);
free(lp700File);
Expand Down

0 comments on commit d5cd2ae

Please sign in to comment.