Same bug, different place. Don't treat a length of zero as "please
strlen() it", because real files and properties can have lengths of zero.
This commit is contained in:
parent
239077599c
commit
3a6bc316ed
2 changed files with 3 additions and 4 deletions
|
@ -90,7 +90,7 @@ FGNasalScript* FGNasalSys::parseScript(const char* src, const char* name)
|
||||||
name = buf;
|
name = buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
script->_code = parse(name, src);
|
script->_code = parse(name, src, strlen(src));
|
||||||
if(naIsNil(script->_code)) {
|
if(naIsNil(script->_code)) {
|
||||||
delete script;
|
delete script;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -454,7 +454,6 @@ void FGNasalSys::initModule(const char* moduleName, const char* fileName,
|
||||||
|
|
||||||
naRef FGNasalSys::parse(const char* filename, const char* buf, int len)
|
naRef FGNasalSys::parse(const char* filename, const char* buf, int len)
|
||||||
{
|
{
|
||||||
if(len == 0) len = strlen(buf);
|
|
||||||
int errLine = -1;
|
int errLine = -1;
|
||||||
naRef srcfile = naNewString(_context);
|
naRef srcfile = naNewString(_context);
|
||||||
naStr_fromdata(srcfile, (char*)filename, strlen(filename));
|
naStr_fromdata(srcfile, (char*)filename, strlen(filename));
|
||||||
|
@ -477,7 +476,7 @@ bool FGNasalSys::handleCommand(const SGPropertyNode* arg)
|
||||||
// location in the property tree. arg->getPath() returns an empty
|
// location in the property tree. arg->getPath() returns an empty
|
||||||
// string.
|
// string.
|
||||||
const char* nasal = arg->getStringValue("script");
|
const char* nasal = arg->getStringValue("script");
|
||||||
naRef code = parse("<command>", nasal);
|
naRef code = parse("<command>", nasal, strlen(nasal));
|
||||||
if(naIsNil(code)) return false;
|
if(naIsNil(code)) return false;
|
||||||
|
|
||||||
// Cache the command argument for inspection via cmdarg(). For
|
// Cache the command argument for inspection via cmdarg(). For
|
||||||
|
|
|
@ -59,7 +59,7 @@ private:
|
||||||
void readScriptFile(SGPath file, const char* lib);
|
void readScriptFile(SGPath file, const char* lib);
|
||||||
void hashset(naRef hash, const char* key, naRef val);
|
void hashset(naRef hash, const char* key, naRef val);
|
||||||
void logError();
|
void logError();
|
||||||
naRef parse(const char* filename, const char* buf, int len=0);
|
naRef parse(const char* filename, const char* buf, int len);
|
||||||
naRef genPropsModule();
|
naRef genPropsModule();
|
||||||
naRef propNodeGhost(SGPropertyNode* handle);
|
naRef propNodeGhost(SGPropertyNode* handle);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue