Forgot to add overflow protection into _lua_freopen function too
This commit is contained in:
Wohlstand 2016-03-24 12:31:56 +03:00
parent e2fd9f5288
commit ee4a518ae1

View File

@ -32,8 +32,10 @@ FILE *_lua_freopen(const char *filename, const char *mode, FILE * oldfile)
wchar_t path[MAX_PATH];
wchar_t wmode[MAX_PATH];
int new_Len1 = MultiByteToWideChar(CP_UTF8, 0, filename, fn_len_s, path, fn_len_s);
if(new_Len1>=MAX_PATH) return NULL;
path[new_Len1] = L'\0';
int new_Len2 = MultiByteToWideChar(CP_UTF8, 0, mode, m_len_s, wmode, m_len_s);
if(new_Len2>=MAX_PATH) return NULL;
wmode[new_Len2] = L'\0';
FILE *f = _wfreopen(path, wmode, oldfile);
LocalFree(path);