mirror of
https://github.com/janet-lang/janet
synced 2024-11-18 14:44:48 +00:00
Fix null check.
This commit is contained in:
parent
0aded71343
commit
7344a6cfc0
@ -764,7 +764,9 @@ static JanetAssembleResult janet_asm1(JanetAssembler *parent, Janet source, int
|
|||||||
x = janet_get1(s, janet_ckeywordv("environments"));
|
x = janet_get1(s, janet_ckeywordv("environments"));
|
||||||
if (janet_indexed_view(x, &arr, &count)) {
|
if (janet_indexed_view(x, &arr, &count)) {
|
||||||
def->environments_length = count;
|
def->environments_length = count;
|
||||||
|
if (def->environments_length) {
|
||||||
def->environments = janet_realloc(def->environments, def->environments_length * sizeof(int32_t));
|
def->environments = janet_realloc(def->environments, def->environments_length * sizeof(int32_t));
|
||||||
|
}
|
||||||
for (int32_t i = 0; i < count; i++) {
|
for (int32_t i = 0; i < count; i++) {
|
||||||
if (!janet_checkint(arr[i])) {
|
if (!janet_checkint(arr[i])) {
|
||||||
janet_asm_error(&a, "expected integer");
|
janet_asm_error(&a, "expected integer");
|
||||||
@ -772,7 +774,7 @@ static JanetAssembleResult janet_asm1(JanetAssembler *parent, Janet source, int
|
|||||||
def->environments[i] = janet_unwrap_integer(arr[i]);
|
def->environments[i] = janet_unwrap_integer(arr[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (NULL == def->environments) {
|
if (def->environments_length && NULL == def->environments) {
|
||||||
JANET_OUT_OF_MEMORY;
|
JANET_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user