From 7be11742b57a0b59eb05d5b33745f2837dad8641 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Fri, 30 Jul 2021 23:22:00 +0200 Subject: [PATCH] VariantParser: Fix uninitialized ResourceParser funcs They could cause a segfault when parsing values with ID "Resource" as apparently we never set a valid `func` for it. Fixes crash part of #42115. (cherry picked from commit f3aaa713d9296bae68a6db91157a2063f01fddc5) --- core/variant_parser.h | 9 ++++----- scene/resources/resource_format_text.cpp | 1 - 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/core/variant_parser.h b/core/variant_parser.h index 0cafe83f045..93fb3a8b323 100644 --- a/core/variant_parser.h +++ b/core/variant_parser.h @@ -76,11 +76,10 @@ public: typedef Error (*ParseResourceFunc)(void *p_self, Stream *p_stream, Ref &r_res, int &line, String &r_err_str); struct ResourceParser { - - void *userdata; - ParseResourceFunc func; - ParseResourceFunc ext_func; - ParseResourceFunc sub_func; + void *userdata = nullptr; + ParseResourceFunc func = nullptr; + ParseResourceFunc ext_func = nullptr; + ParseResourceFunc sub_func = nullptr; }; enum TokenType { diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index 709366444c3..55695c365c9 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -898,7 +898,6 @@ void ResourceInteractiveLoaderText::open(FileAccess *p_f, bool p_skip_first_tag) rp.ext_func = _parse_ext_resources; rp.sub_func = _parse_sub_resources; - rp.func = NULL; rp.userdata = this; }