From 1b2f22fd68a2e50cabdfe2e036096cc9e7a05a1f Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Fri, 5 Jan 2018 14:44:10 -0800 Subject: Convert existing websocket and http code to use new URL framework. This also fixes a use-after-free bug in the HTTP framework, where the handler could be deleted why callbacks were still using it. (We now reference count the handlers.) --- src/core/url.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/core/url.c') diff --git a/src/core/url.c b/src/core/url.c index 8dee5219..8cb5a2e7 100644 --- a/src/core/url.c +++ b/src/core/url.c @@ -1,6 +1,6 @@ // -// Copyright 2017 Garrett D'Amore -// Copyright 2017 Capitar IT Group BV +// Copyright 2018 Staysail Systems, Inc. +// Copyright 2018 Capitar IT Group BV // // This software is supplied under the terms of the MIT License, a // copy of which should be located in the distribution where this @@ -250,13 +250,17 @@ nni_url_parse(nni_url **urlp, const char *raw) } if ((url->u_host = nni_alloc(len + 1)) == NULL) { - nni_url_free(url); - return (NNG_ENOMEM); + rv = NNG_ENOMEM; + goto error; } memcpy(url->u_host, s, len); url->u_host[len] = '\0'; s += len; + if ((url->u_rawpath = nni_strdup(s)) == NULL) { + rv = NNG_ENOMEM; + goto error; + } for (len = 0; (c = s[len]) != '\0'; len++) { if ((c == '?') || (c == '#')) { break; @@ -363,5 +367,6 @@ nni_url_free(nni_url *url) nni_strfree(url->u_path); nni_strfree(url->u_query); nni_strfree(url->u_fragment); + nni_strfree(url->u_rawpath); NNI_FREE_STRUCT(url); } \ No newline at end of file -- cgit v1.2.3-70-g09d2