Merge pull request #5 from JustJ3di/main

bug fix
This commit is contained in:
Francesco Cozzuto
2022-04-02 01:14:45 +02:00
committed by GitHub
+17 -4
View File
@@ -60,11 +60,15 @@ 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;
@@ -72,6 +76,15 @@ static Object *bin_unicode(Runtime *runtime, Object **argv, unsigned int argc, E
if (string == NULL)
return NULL;
if (n == 0)
{
Error_Report(error, 0, "Argument #%d is empty string", 1);
return NULL;
}
int k = utf8_sequence_to_utf32_codepoint(string,n,&ret);
assert(k>=0);