1
0
Fork 0

DBG: fixed out of bounds access when loading an empty script

This commit is contained in:
mrexodia 2017-03-23 13:39:17 +01:00
parent 3df04e55d9
commit 7fbb9afb82
No known key found for this signature in database
GPG Key ID: FC89E0AAA0C1AAD8
1 changed files with 2 additions and 2 deletions

View File

@ -142,7 +142,7 @@ static bool scriptcreatelinemap(const char* filename)
linemap.push_back(entry);
}
int linemapsize = (int)linemap.size();
while(!*linemap.at(linemapsize - 1).raw) //remove empty lines from the end
while(linemapsize && !*linemap.at(linemapsize - 1).raw) //remove empty lines from the end
{
linemapsize--;
linemap.pop_back();
@ -249,7 +249,7 @@ static bool scriptcreatelinemap(const char* filename)
currentLine.u.branch.dest = scriptinternalstep(labelline);
}
}
if(linemap.at(linemapsize - 1).type == linecomment || linemap.at(linemapsize - 1).type == linelabel) //label/comment on the end
if(linemapsize && (linemap.at(linemapsize - 1).type == linecomment || linemap.at(linemapsize - 1).type == linelabel)) //label/comment on the end
{
memset(&entry, 0, sizeof(entry));
entry.type = linecommand;