Skip to content

Commit d428140

Browse files
committed
Initialize socket before trying to connect HTTP endpoint
1 parent 0dd3b06 commit d428140

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/net/http.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,8 @@ xhttp_status_t XHTTP_Exchange(xhttp_t *pRequest, xhttp_t *pResponse, xsock_t *pS
10101010

10111011
xhttp_status_t XHTTP_Connect(xhttp_t *pHttp, xsock_t *pSock, xlink_t *pLink)
10121012
{
1013+
XSock_Init(pSock, XSTDNON, XSOCK_INVALID);
1014+
10131015
if (!xstrused(pLink->sProtocol)) xstrncpy(pLink->sProtocol, sizeof(pLink->sProtocol), "http");
10141016
if (strncmp(pLink->sProtocol, "http", 4)) return XHTTP_StatusCb(pHttp, XHTTP_ERRPROTO);
10151017

src/net/sock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ XSTATUS XSock_Init(xsock_t *pSock, uint32_t nFlags, XSOCKET nFD)
512512
void XSock_Close(xsock_t *pSock)
513513
{
514514
#ifdef XSOCK_USE_SSL
515-
if (pSock->pPrivate != NULL)
515+
if (pSock && pSock->pPrivate != NULL)
516516
{
517517
xsock_priv_t *pPriv = (xsock_priv_t*)pSock->pPrivate;
518518
SSL *pSSL = (SSL*)pPriv->pSSL;
@@ -533,7 +533,7 @@ void XSock_Close(xsock_t *pSock)
533533
}
534534
#endif
535535

536-
if (pSock->nFD != XSOCK_INVALID)
536+
if (pSock && pSock->nFD != XSOCK_INVALID)
537537
{
538538
shutdown(pSock->nFD, XSHUT_RDWR);
539539
xclosesock(pSock->nFD);

src/xver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#define XUTILS_VERSION_MAX 2
1414
#define XUTILS_VERSION_MIN 7
15-
#define XUTILS_BUILD_NUMBER 7
15+
#define XUTILS_BUILD_NUMBER 8
1616
#define XUTILS_BUILD_DATE "05Oct2025"
1717

1818
#ifdef __cplusplus

0 commit comments

Comments
 (0)