From 2c3dd51d3d520cc658ea6dd198eb8bcd7e7d91a6 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 11 Jun 2015 19:30:20 +0000 Subject: crash fix git-svn-id: http://svn.miranda-ng.org/main/trunk@14121 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- src/modules/netlib/netlibautoproxy.cpp | 2 +- src/modules/netlib/netlibopenconn.cpp | 28 ++++++++++++++++------------ 2 files changed, 17 insertions(+), 13 deletions(-) (limited to 'src/modules/netlib') diff --git a/src/modules/netlib/netlibautoproxy.cpp b/src/modules/netlib/netlibautoproxy.cpp index f0b8464a2f..6410c49e74 100644 --- a/src/modules/netlib/netlibautoproxy.cpp +++ b/src/modules/netlib/netlibautoproxy.cpp @@ -164,7 +164,7 @@ bool NetlibGetIeProxyConn(NetlibConnection *nlc, bool forceHttps) { bool noHttp = false; bool usingSsl = false; - char szUrl[256] = ""; + char szUrl[256]; if ((nlc->nloc.flags & (NLOCF_HTTP | NLOCF_HTTPGATEWAY) && nlc->nloc.flags & NLOCF_SSL) || nlc->nloc.wPort == 443 || forceHttps) diff --git a/src/modules/netlib/netlibopenconn.cpp b/src/modules/netlib/netlibopenconn.cpp index 894899be2f..1eb1ba633c 100644 --- a/src/modules/netlib/netlibopenconn.cpp +++ b/src/modules/netlib/netlibopenconn.cpp @@ -704,18 +704,22 @@ bool NetlibDoConnect(NetlibConnection *nlc) } while (!my_connect(nlc, nloc)) { - // Fallback to direct only when using HTTP proxy, as this is what used by companies - // If other type of proxy used it's an indication of security nutcase, leave him alone - if (usingProxy && (nlc->proxyType == PROXYTYPE_HTTPS || nlc->proxyType == PROXYTYPE_HTTP)) { - usingProxy = false; - nlc->proxyType = 0; - NetlibLogf(nlu, "Fallback to direct connection"); - continue; - } - if (nlu->settings.useProxy && !usingProxy && nlu->settings.proxyType == PROXYTYPE_IE && !forceHttps) { - forceHttps = true; - usingProxy = NetlibGetIeProxyConn(nlc, true); - if (usingProxy) continue; + // if connection failed, the state of nlc might be unpredictable + if (GetNetlibHandleType(nlc) == NLH_CONNECTION) { + // Fallback to direct only when using HTTP proxy, as this is what used by companies + // If other type of proxy used it's an indication of security nutcase, leave him alone + if (usingProxy && (nlc->proxyType == PROXYTYPE_HTTPS || nlc->proxyType == PROXYTYPE_HTTP)) { + usingProxy = false; + nlc->proxyType = 0; + NetlibLogf(nlu, "Fallback to direct connection"); + continue; + } + if (nlu->settings.useProxy && !usingProxy && nlu->settings.proxyType == PROXYTYPE_IE && !forceHttps) { + forceHttps = true; + usingProxy = NetlibGetIeProxyConn(nlc, true); + if (usingProxy) + continue; + } } NetlibLogf(nlu, "%s %d: %s() failed (%u)", __FILE__, __LINE__, "connect", WSAGetLastError()); return false; -- cgit v1.2.3