Skip to content

Commit 62dc131

Browse files
committed
Merge pull request #109172 from mihe/printraw-overflow
Fix `printraw` causing infinite recursion in `Logger._log_message`
2 parents 4b23f09 + 494471d commit 62dc131

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

core/string/print_string.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,19 @@ void __print_line_rich(const String &p_string) {
298298
is_printing = false;
299299
}
300300

301+
void print_raw(const String &p_string) {
302+
if (is_printing) {
303+
__print_fallback(p_string, true);
304+
return;
305+
}
306+
307+
is_printing = true;
308+
309+
OS::get_singleton()->print("%s", p_string.utf8().get_data());
310+
311+
is_printing = false;
312+
}
313+
301314
void print_error(const String &p_string) {
302315
if (!CoreGlobals::print_error_enabled) {
303316
return;

core/string/print_string.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ void remove_print_handler(const PrintHandlerList *p_handler);
5757

5858
extern void __print_line(const String &p_string);
5959
extern void __print_line_rich(const String &p_string);
60+
extern void print_raw(const String &p_string);
6061
extern void print_error(const String &p_string);
6162
extern bool is_print_verbose_enabled();
6263

core/variant/variant_utility.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ void VariantUtilityFunctions::prints(const Variant **p_args, int p_arg_count, Ca
10111011
}
10121012

10131013
void VariantUtilityFunctions::printraw(const Variant **p_args, int p_arg_count, Callable::CallError &r_error) {
1014-
OS::get_singleton()->print("%s", join_string(p_args, p_arg_count).utf8().get_data());
1014+
print_raw(join_string(p_args, p_arg_count));
10151015
r_error.error = Callable::CallError::CALL_OK;
10161016
}
10171017

0 commit comments

Comments
 (0)