From 06bc73976f4f0f0bfdd127d5d0244ae7df2b31b5 Mon Sep 17 00:00:00 2001 From: disarray2077 <86157825+disarray2077@users.noreply.github.com> Date: Fri, 25 Feb 2022 21:26:56 -0300 Subject: [PATCH] Correctly handle null in `Write`/`WriteLine` --- BeefLibs/corlib/src/Console.bf | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/BeefLibs/corlib/src/Console.bf b/BeefLibs/corlib/src/Console.bf index edc0df8f..eb6d2ee1 100644 --- a/BeefLibs/corlib/src/Console.bf +++ b/BeefLibs/corlib/src/Console.bf @@ -221,7 +221,10 @@ namespace System public static void Write(Object obj) { String str = scope String(256); - obj.ToString(str); + if (obj == null) + str.Append("null"); + else + obj.ToString(str); Write(str); } @@ -245,7 +248,10 @@ namespace System public static void WriteLine(Object obj) { String str = scope String(256); - obj.ToString(str); + if (obj == null) + str.Append("null"); + else + obj.ToString(str); WriteLine(str); }