Fix bug empity string

Added a control if the string in the build in funcion unicode() is empity
This commit is contained in:
Herman
2022-04-01 20:25:28 +02:00
committed by GitHub
parent f3880fad79
commit f53c3b2052
+17 -4
View File
@@ -58,17 +58,30 @@ static Object *bin_unicode(Runtime *runtime, Object **argv, unsigned int argc, E
(void) runtime; (void) runtime;
(void) error; (void) error;
uint32_t ret = 0; uint32_t ret = 0;
if(!Object_IsString(argv[0])){
Error_Report(error, 0, "Argument #%d is not a string", 1); if(!Object_IsString(argv[0]))
return NULL; {
}
Error_Report(error, 0, "Argument #%d is not a string", 1);
return NULL;
}
const char *string; const char *string;
int n; int n;
string = Object_ToString(argv[0],&n,Runtime_GetHeap(runtime),error); string = Object_ToString(argv[0],&n,Runtime_GetHeap(runtime),error);
if (string == NULL) if (string == NULL)
return 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); int k = utf8_sequence_to_utf32_codepoint(string,n,&ret);