Преглед на файлове

libobs/callback: Catch fail cases with missing error data

In `parse_decl_string`, it jumps to `fail` label if an error occurs.
However, if the lexer encountered an error for example, `cfp.error_list`
may be empty.
Norihiro Kamae преди 6 месеца
родител
ревизия
220b0ec649
променени са 1 файла, в които са добавени 4 реда и са изтрити 2 реда
  1. 4 2
      libobs/callback/decl.c

+ 4 - 2
libobs/callback/decl.c

@@ -182,7 +182,7 @@ bool parse_decl_string(struct decl_info *decl, const char *decl_string)
 	struct strref ret_type;
 	struct decl_param ret_param = {0};
 	int code;
-	bool success;
+	bool success = false;
 
 	decl->decl_string = decl_string;
 	ret_param.flags = CALL_PARAM_OUT;
@@ -210,9 +210,11 @@ bool parse_decl_string(struct decl_info *decl, const char *decl_string)
 		goto fail;
 
 	parse_params(&cfp, decl);
+	success = true;
 
 fail:
-	success = !error_data_has_errors(&cfp.error_list);
+	if (error_data_has_errors(&cfp.error_list))
+		success = false;
 
 	if (success && ret_param.type != CALL_PARAM_TYPE_VOID) {
 		ret_param.name = bstrdup("return");