rem: lhost = Tcl_GetString(objv[++first]);
add: if (++first >= objc) { goto syntax; } lhost = Tcl_GetString(objv[first]);
context: NsTclSockOpenObjCmd(    ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]){    SOCKET sock;    char *host, *lhost = NULL, *opt, *val;    int lport = 0, port, first, async = 0, timeout = -1;    if (objc < 3 || objc > 9) {      syntax:        Tcl_WrongNumArgs(interp, 1, objv,                "?(-nonblock | -async) | -timeout seconds? "                "?-localhost host? ?-localport port? host port");        return TCL_ERROR;    }        /*     * Parse optional arguments.  Note that either the:     *     -nonblock | -async     * or     *     -timeout seconds     * combinations are accepted.     */    for (first = 1; first < objc; first++) {        opt= Tcl_GetString(objv[first]);        if (*opt != '-') {            break; /* End of options */        }        if (STREQ(opt, "-nonblock") || STREQ(opt, "-async")) {            if (timeout >= 0) {                goto syntax;            }            async = 1;        } else if (STREQ(opt, "-localhost")) {            lhost = Tcl_GetString(objv[++first]);            if (*lhost == 0) {                goto badhost;            }        } else if (STREQ(opt, "-timeout")) {            if (async) {                goto syntax;            }            if (Tcl_GetIntFromObj(interp, objv[++first], &timeout) != TCL_OK) {                return TCL_ERROR;            }        } else if (STREQ(opt, "-localport")) {            if (Tcl_GetIntFromObj(interp, objv[++first], &lport) != TCL_OK) {                return TCL_ERROR;            }            if (port < 0) {                val = Tcl_GetString(objv[first+1]);                goto badport;            }        } else {            Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),                    "invalid option: \"", opt, "\"", NULL);            return TCL_ERROR;           }    }        if ((objc - first) != 2) {        goto syntax;    }    /*     * Get the host to connect to. Bark on invalid entry.     */    host = Tcl_GetString(objv[first]);    if (*host == 0) {      badhost:        Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),                "invalid hostname: must not be empty", NULL);        return TCL_ERROR;    }    /*     * Get the port to connect to. Bark on invalid entry.     */    if (Tcl_GetIntFromObj(interp, objv[first+1], &port) != TCL_OK) {        return TCL_ERROR;    } else if (port < 0) {      badport:        val = Tcl_GetString(objv[first+1]);        Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),                "invalid port: ", val, "; must be positive integer", NULL);        return TCL_ERROR;    }    /*     * Perform the connection.     */    if (async) {        sock = Ns_SockAsyncConnect2(host, port, lhost, lport);    } else if (timeout < 0) {        sock = Ns_SockConnect2(host, port, lhost, lport);    } else {        sock = Ns_SockTimedConnect2(host, port, lhost, lport, timeout);    }    if (sock == INVALID_SOCKET) {        char *why = Tcl_GetErrno() ? Tcl_PosixError(interp) : "reason unknown";        Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),                "can't connect to \"", host, ":",                Tcl_GetString(objv[first+1]), "\"; ", why, NULL);        return TCL_ERROR;    }    return EnterDupedSocks(interp, sock);}