avoid another crash in case of malformed raw files (if raw->npoints not allocated return without attempting to read raw file)

This commit is contained in:
stefan schippers 2024-11-01 00:27:29 +01:00
parent bc273f5344
commit f3abdf2eb8
2 changed files with 3 additions and 7 deletions

View File

@ -404,7 +404,7 @@ static void read_binary_block(FILE *fd, Raw *raw, int ac)
int npoints;
int rawvars = raw->nvars;
if(!raw) {
if(!raw || !raw->npoints) {
dbg(0, "read_binary_block() no raw struct allocated\n");
return;
}

View File

@ -4303,13 +4303,9 @@ const char *translate2(Lcc *lcc, int level, char* s)
}
else escape = 0;
space = SPACE(c);
if( state==TOK_BEGIN && (c=='@' || c=='%' ) && !escape ) state=TOK_TOKEN;
if( state==TOK_BEGIN && (c=='@' || c=='%' ) ) state=TOK_TOKEN;
else if(state==TOK_TOKEN && token_pos > 1 &&
(
( (space || c == '%' || c == '@') && !escape ) ||
( (!space && c != '%' && c != '@') && escape )
)
) state = TOK_SEP;
( ( (space || c == '%' || c == '@') ) || escape) ) state = TOK_SEP;
STR_ALLOC(&result, result_pos, &size);
STR_ALLOC(&token, token_pos, &sizetok);
if (state == TOK_TOKEN) token[token_pos++] = (char)c;