Scripting: Fix some Lua string handling

This commit is contained in:
Vicki Pfau 2023-04-05 04:50:26 -07:00
parent 2f54d98ff6
commit 8c55769afc
1 changed files with 4 additions and 2 deletions

View File

@ -894,7 +894,9 @@ bool _luaLoad(struct mScriptEngineContext* ctx, const char* filename, struct VFi
luaContext->lastError = NULL;
}
char name[PATH_MAX + 1];
char dirname[PATH_MAX] = {0};
char dirname[PATH_MAX];
name[0] = '\0';
dirname[0] = '\0';
if (filename) {
if (*filename == '*') {
snprintf(name, sizeof(name), "=%s", filename + 1);
@ -909,7 +911,7 @@ bool _luaLoad(struct mScriptEngineContext* ctx, const char* filename, struct VFi
lastSlash = lastBackslash;
}
if (lastSlash) {
strncpy(dirname, filename, lastSlash - filename);
strlcpy(dirname, filename, lastSlash - filename);
}
snprintf(name, sizeof(name), "@%s", filename);
}