Commit 378aa525 authored by Augustin Degomme's avatar Augustin Degomme
Browse files

try to avoid segfaulting when loading trace finishing with an incomplete line in Paje

parent 7f3186f4
......@@ -161,10 +161,14 @@ int PajeFileManager::get_line(PajeLine *lineptr) {
}
// Start a long token
while ( (_line[i] != '\'')) {
while ( ( i < _filesize) && (_line[i] != '\'')) {
i++;
}
if((i==_filesize)){
setstate(ifstream::eofbit);
throw "Overflow";
return -1;
}
// We finish the token by replacing the \' by \0
_line[i] = '\0';
if(i+1<_line.size()){//begin a new token if we are not at the end of the line
......@@ -186,7 +190,7 @@ int PajeFileManager::get_line(PajeLine *lineptr) {
}
// Start a long token (-1 to have place or the null caractere)
while ( (_line[i] != '"')) {
while (( i < _filesize) && (_line[i] != '"')) {
i++;
}
......@@ -196,16 +200,27 @@ int PajeFileManager::get_line(PajeLine *lineptr) {
itks++;
_tokens[itks] = &_line[i+1];
}
if((i==_filesize)){
setstate(ifstream::eofbit);
throw "Overflow";
return -1;
}
break;
}
case ' ' :
case '\t' :
{
// Skip all spaces
while (i<_line.size() && ((_line[i] == ' ') || (_line[i] == '\t')) ) {
while (( i < _filesize) && i<_line.size() && ((_line[i] == ' ') || (_line[i] == '\t')) ) {
_line[i] = '\0';
i++;
}
if((i==_filesize)){
setstate(ifstream::eofbit);
throw "Overflow";
return -1;
}
// We store a new token if it's a new space
if(i!=_line.size()){
if (_tokens[itks]!=NULL && _tokens[itks][0] != '\0')
......
......@@ -304,11 +304,17 @@ int mt_PajeFileManager::get_line(PajeLine *lineptr) {
case '\t' :
{
// Skip all spaces
while ( (i < max_offset-1 ) &&
while ( (i<_filesize) && (i < max_offset-1 ) &&
((_line[i] == ' ') || (_line[i] == '\t')) ) {
_line[i] = '\0';
_line[i] = '\0';
i++;
}
if((i==_filesize)){
_eof=true;
throw "Overflow";
return -1;
}
// We store a new token if it's a new space
if (_tokens[itks][0] != '\0')
itks++;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment