Răsfoiți Sursa

libobs/util: Fix potential memory error in text parser

Fixes memory access when parsing '#' comment tokens when the file
immediately was EOF after this token.
Florian Zwoch 1 an în urmă
părinte
comite
e36352dadd
1 a modificat fișierele cu 3 adăugiri și 2 ștergeri
  1. 3 2
      libobs/util/text-lookup.c

+ 3 - 2
libobs/util/text-lookup.c

@@ -88,8 +88,9 @@ static bool lookup_gettoken(struct lexer *lex, struct strref *str)
 		if (!str->array) {
 		if (!str->array) {
 			/* comments are designated with a #, and end at LF */
 			/* comments are designated with a #, and end at LF */
 			if (ch == '#') {
 			if (ch == '#') {
-				while (ch != '\n' && ch != 0)
-					ch = *(++lex->offset);
+				while (*lex->offset != '\n' &&
+				       *lex->offset != 0)
+					++lex->offset;
 			} else if (temp.type == BASETOKEN_WHITESPACE) {
 			} else if (temp.type == BASETOKEN_WHITESPACE) {
 				strref_copy(str, &temp.text);
 				strref_copy(str, &temp.text);
 				break;
 				break;