From f11fb9d3cb188ba2ffaae4069d7c04f3b10262b1 Mon Sep 17 00:00:00 2001 From: Bryan Roe Date: Mon, 24 Feb 2020 15:45:15 -0800 Subject: [PATCH] Fixed bug, where if DNS resolve fails, an attempt is made to fetch cache results, but the result was accidentally left on the value stack --- microscript/ILibDuktape_net.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/microscript/ILibDuktape_net.c b/microscript/ILibDuktape_net.c index 6eea4bd..4e6f90c 100644 --- a/microscript/ILibDuktape_net.c +++ b/microscript/ILibDuktape_net.c @@ -456,12 +456,13 @@ duk_ret_t ILibDuktape_net_socket_connect(duk_context *ctx) if (duk_has_prop_string(ctx, -1, "_sharedDB")) { ILibSimpleDataStore db = (ILibSimpleDataStore)Duktape_GetPointerProperty(ctx, -1, "_sharedDB"); - char *dnsCache = (char*)duk_push_sprintf(ctx, "DNS[%s]", host); + char *dnsCache = (char*)duk_push_sprintf(ctx, "DNS[%s]", host); // [dnsCache] char dnsCacheBuffer[255]; if (ILibSimpleDataStore_Get(db, dnsCache, dnsCacheBuffer, sizeof(dnsCacheBuffer)) > 0) { ILibResolveEx(dnsCacheBuffer, (unsigned short)port, &dest); } + duk_pop(ctx); // ... } } if (dest.sin6_family == AF_UNSPEC || (duk_is_object(ctx, 0) && duk_has_prop_string(ctx, 0, "proxy") && proxy.sin6_family == AF_UNSPEC))