1
0
mirror of https://github.com/janet-lang/janet synced 2025-11-29 13:35:13 +00:00

Address #336 case 3

Fix error condition for bad abstract types - don't return NULL, panic.
This commit is contained in:
Calvin Rose
2020-04-05 17:38:14 -05:00
parent 553e38ffd6
commit 5bbd507858
3 changed files with 11 additions and 9 deletions

View File

@@ -1098,7 +1098,7 @@ static const uint8_t *unmarshal_one_abstract(UnmarshalState *st, const uint8_t *
Janet key;
data = unmarshal_one(st, data, &key, flags + 1);
const JanetAbstractType *at = janet_get_abstract_type(key);
if (at == NULL) return NULL;
if (at == NULL) goto oops;
if (at->unmarshal) {
JanetMarshalContext context = {NULL, st, flags, data, at};
*out = janet_wrap_abstract(at->unmarshal(&context));
@@ -1107,7 +1107,8 @@ static const uint8_t *unmarshal_one_abstract(UnmarshalState *st, const uint8_t *
}
return context.data;
}
return NULL;
oops:
janet_panic("invalid abstract type");
}
static const uint8_t *unmarshal_one(