From 4f49d09272d4885629bdde484edea875d9b45c94 Mon Sep 17 00:00:00 2001 From: Hein-Pieter van Braam Date: Fri, 22 Feb 2019 19:27:13 +0100 Subject: Don't crash when parse_utf8 receives a NULL pointer This can happen when chaining calls to various string methods when the string is empty. --- main/tests/test_string.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'main') diff --git a/main/tests/test_string.cpp b/main/tests/test_string.cpp index 511646db0a..edc4fb0c97 100644 --- a/main/tests/test_string.cpp +++ b/main/tests/test_string.cpp @@ -1046,6 +1046,13 @@ bool test_32() { #undef STRIP_TEST } +bool test_33() { + OS::get_singleton()->print("\n\nTest 33: parse_utf8(null, -1)\n"); + + String empty; + return empty.parse_utf8(NULL, -1) == true; +} + typedef bool (*TestFunc)(void); TestFunc test_funcs[] = { @@ -1082,6 +1089,7 @@ TestFunc test_funcs[] = { test_30, test_31, test_32, + test_33, 0 }; -- cgit v1.2.3