Check type when getting socket type
janet_get_sockettype expects a keyword but we're making it optional that
the call to the functions that use it with arity >=3 will be guaranteed
to have it as a keyword value! If it's not a keyword then it's the same
as NULL.
@@ -248,7 +248,9 @@ JANET_NO_RETURN static void janet_sched_accept(JanetStream *stream, JanetFunctio
/* Adress info */
static int janet_get_sockettype(Janet *argv, int32_t argc, int32_t n) {
- JanetKeyword stype = janet_optkeyword(argv, argc, n, NULL);
+ JanetKeyword stype = NULL;
+ if(janet_checktype(argv[n], JANET_KEYWORD))
+ stype = janet_optkeyword(argv, argc, n, NULL);
int socktype = SOCK_DGRAM;
if ((NULL == stype) || !janet_cstrcmp(stype, "stream")) {
socktype = SOCK_STREAM;
