Skip to content

Commit

Permalink
IdTech1Converter: Addressed a potential access violation, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Sep 29, 2014
1 parent f0509d6 commit d9171ef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion doomsday/plugins/idtech1converter/src/idtech1converter.cpp
Expand Up @@ -32,8 +32,9 @@ static inline AutoStr *readFileIntoString(String const &path, bool *isCustom = 0
{
dd_bool _isCustom;
ddstring_t sourcePath;
AutoStr *string = M_ReadFileIntoString(Str_InitStatic(&sourcePath, path.toUtf8().constData()), &_isCustom);
AutoStr *string = M_ReadFileIntoString(Str_Set(Str_InitStd(&sourcePath), path.toUtf8().constData()), &_isCustom);
if(isCustom) *isCustom = _isCustom;
Str_Free(&sourcePath);
return string;
}

Expand Down
14 changes: 9 additions & 5 deletions doomsday/plugins/idtech1converter/src/mapinfotranslator.cpp
Expand Up @@ -1278,18 +1278,22 @@ void MapInfoTranslator::merge(ddstring_s const &definitions, String sourcePath,

if(Str_IsEmpty(&definitions)) return;

d->translatedFiles << sourcePath;
String const source = sourcePath.isEmpty()? "[definition-data]"
: ("\"" + NativePath(sourcePath).pretty() + "\"");
try
{
LOG_RES_VERBOSE("Parsing \"%s\"...") << NativePath(sourcePath).pretty();
if(!sourcePath.isEmpty())
{
LOG_RES_VERBOSE("Parsing %s...") << source;
d->translatedFiles << sourcePath;
}

MapInfoParser parser(d->defs);
parser.parse(definitions, sourcePath);
}
catch(MapInfoParser::ParseError const &er)
{
LOG_WARNING("Failed to parse \"%s\" as MAPINFO:\n")
<< (sourcePath.isEmpty()? "[definition-data]" : sourcePath)
<< er.asText();
LOG_WARNING("Failed to parse %s as MAPINFO:\n") << source << er.asText();
}
}

Expand Down

0 comments on commit d9171ef

Please sign in to comment.