mirror of
https://github.com/janet-lang/janet
synced 2024-12-26 16:30:26 +00:00
Fix null check.
This commit is contained in:
parent
282546c03f
commit
7663b1e703
@ -725,7 +725,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");
|
||||||
@ -733,7 +735,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