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;
|
||||
}
|
||||
|
||||
script->_code = parse(name, src);
|
||||
script->_code = parse(name, src, strlen(src));
|
||||
if(naIsNil(script->_code)) {
|
||||
delete script;
|
||||
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)
|
||||
{
|
||||
if(len == 0) len = strlen(buf);
|
||||
int errLine = -1;
|
||||
naRef srcfile = naNewString(_context);
|
||||
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
|
||||
// string.
|
||||
const char* nasal = arg->getStringValue("script");
|
||||
naRef code = parse("<command>", nasal);
|
||||
naRef code = parse("<command>", nasal, strlen(nasal));
|
||||
if(naIsNil(code)) return false;
|
||||
|
||||
// Cache the command argument for inspection via cmdarg(). For
|
||||
|
|
|
@ -59,7 +59,7 @@ private:
|
|||
void readScriptFile(SGPath file, const char* lib);
|
||||
void hashset(naRef hash, const char* key, naRef val);
|
||||
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 propNodeGhost(SGPropertyNode* handle);
|
||||
|
||||
|
|
Loading…
Reference in a new issue