From f53c3b205228e5598739d58c8f93094d1b98a94e Mon Sep 17 00:00:00 2001 From: Herman <55718523+JustJ3di@users.noreply.github.com> Date: Fri, 1 Apr 2022 20:25:28 +0200 Subject: [PATCH 1/2] Fix bug empity string Added a control if the string in the build in funcion unicode() is empity --- src/builtins/basic.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/builtins/basic.c b/src/builtins/basic.c index 5e4dad0..f4d5b30 100644 --- a/src/builtins/basic.c +++ b/src/builtins/basic.c @@ -58,17 +58,30 @@ static Object *bin_unicode(Runtime *runtime, Object **argv, unsigned int argc, E (void) runtime; (void) error; uint32_t ret = 0; - if(!Object_IsString(argv[0])){ - Error_Report(error, 0, "Argument #%d is not a string", 1); - return NULL; - } + if(!Object_IsString(argv[0])) + { + + Error_Report(error, 0, "Argument #%d is not a string", 1); + return NULL; + } + + const char *string; int n; string = Object_ToString(argv[0],&n,Runtime_GetHeap(runtime),error); if (string == NULL) return NULL; + + if (strcmp("\0",string)== 0) + { + + Error_Report(error, 0, "Argument #%d is empty string", 1); + return NULL; + + } + int k = utf8_sequence_to_utf32_codepoint(string,n,&ret); From 41f62d2415bed2a52932832c2849c695128bc339 Mon Sep 17 00:00:00 2001 From: Herman <55718523+JustJ3di@users.noreply.github.com> Date: Fri, 1 Apr 2022 20:28:22 +0200 Subject: [PATCH 2/2] Update basic.c --- src/builtins/basic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/builtins/basic.c b/src/builtins/basic.c index f4d5b30..b40ed3c 100644 --- a/src/builtins/basic.c +++ b/src/builtins/basic.c @@ -74,7 +74,7 @@ static Object *bin_unicode(Runtime *runtime, Object **argv, unsigned int argc, E if (string == NULL) return NULL; - if (strcmp("\0",string)== 0) + if (n == 0) { Error_Report(error, 0, "Argument #%d is empty string", 1);