mirror of
https://github.com/janet-lang/janet
synced 2024-12-26 00:10:27 +00:00
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.
This commit is contained in:
parent
532dac1b95
commit
6ad016c587
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user