gustavonihei commented on a change in pull request #695:
URL:
https://github.com/apache/incubator-nuttx-apps/pull/695#discussion_r628553765
##########
File path: netutils/webclient/webclient.c
##########
@@ -674,225 +693,336 @@ int webclient_perform(FAR struct webclient_context *ctx)
/* Initialize the state structure */
- ws = calloc(1, sizeof(struct wget_s));
- if (!ws)
+ if (ctx->ws == NULL)
{
- return -errno;
- }
+ ws = calloc(1, sizeof(struct wget_s));
+ if (!ws)
+ {
+ return -errno;
+ }
- ws->buffer = ctx->buffer;
- ws->buflen = ctx->buflen;
+ ws->buffer = ctx->buffer;
+ ws->buflen = ctx->buflen;
- /* Parse the hostname (with optional port number) and filename
- * from the URL.
- */
+ /* Parse the hostname (with optional port number) and filename
+ * from the URL.
+ */
- ret = parseurl(ctx->url, ws);
- if (ret != 0)
- {
- nwarn("WARNING: Malformed URL: %s\n", ctx->url);
- free(ws);
- return ret;
+ ret = parseurl(ctx->url, ws);
+ if (ret != 0)
+ {
+ nwarn("WARNING: Malformed URL: %s\n", ctx->url);
+ free(ws);
Review comment:
```suggestion
free(ws);
ctx->ws = NULL;
```
To avoid use-after-free errors, the freed pointer should be nullified.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]