1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

Fix uninitalized memory accesses in editor.

This commit is contained in:
Jonas 'Sortie' Termansen 2014-07-31 19:35:29 +02:00
parent a8b8514272
commit c451de1bc2

View file

@ -278,6 +278,8 @@ struct editor
void initialize_editor(struct editor* editor) void initialize_editor(struct editor* editor)
{ {
memset(editor, 0, sizeof(*editor));
editor->current_file_name = NULL; editor->current_file_name = NULL;
editor->lines = NULL; editor->lines = NULL;
editor->lines_used = 0; editor->lines_used = 0;
@ -754,10 +756,14 @@ void editor_colorize(struct editor* editor)
continue; continue;
if ( strncmp(line->data + x, keyword, keyword_length) != 0 ) if ( strncmp(line->data + x, keyword, keyword_length) != 0 )
continue; continue;
if ( (x - line->used) != keyword_length &&
(isalnum(line->data[x+keyword_length]) || if ( keyword_length < line->used - x )
line->data[x+keyword_length] == '_') ) {
continue; char c = line->data[x + keyword_length];
if ( isalnum(c) || c == '_' )
continue;
}
state = STATE_KEYWORD; state = STATE_KEYWORD;
fixed_state = keyword_length; fixed_state = keyword_length;
} }