txlyre il y a 8 heures
Parent
commit
50fa9ae664
1 fichiers modifiés avec 4 ajouts et 2 suppressions
  1. 4 2
      qirt.c

+ 4 - 2
qirt.c

@@ -2173,7 +2173,7 @@ qi_value_t *qi_cast(qi_state_t *state, qi_type_t type, qi_value_t *value)
       LOCKED(value, {
         qi_list_t *list = value->value.list;
         length = qi_list_length(list);
-        temp = qi_malloc(length);
+        temp = qi_malloc_atomic(length);
 
         if (!qi_list_empty(list))
           for (qi_size_t i = 0; i < length; i++)
@@ -2183,6 +2183,8 @@ qi_value_t *qi_cast(qi_state_t *state, qi_type_t type, qi_value_t *value)
             if (byte->type != QI_NUMBER)
             {
               qi_mutex_unlock(value->mutex);
+              
+              qi_free(temp);
 
               qi_typeerror(state,
                            "cannot cast %s to %s (expected list of numbers, "
@@ -3096,7 +3098,7 @@ qi_value_t *qi_add(qi_state_t *state, qi_value_t *a, qi_value_t *b)
       return a;
 
     qi_size_t size = a->value.bytes->size + b->value.bytes->size;
-    unsigned char *bytes = qi_malloc(size);
+    unsigned char *bytes = qi_malloc_atomic(size);
 
     memcpy(bytes, a->value.bytes->data, a->value.bytes->size);
     memcpy(bytes + a->value.bytes->size, b->value.bytes->data,