WPS: Cleanup subscription URL list handling

Do not give the allocated memory to the subscription code since it was
not using it as-is anyway. This makes it easier to understand who owns
the allocation an is responsible of freeing it. This may potentially
fix some memory leaks on error paths.
This commit is contained in:
Jouni Malinen 2009-11-21 18:06:02 +02:00
parent ec72bd0c77
commit 3f6dc111ff
3 changed files with 5 additions and 6 deletions

View file

@ -734,13 +734,13 @@ static int subscription_first_event(struct subscription *s)
/** /**
* subscription_start - Rremember a UPnP control point to send events to. * subscription_start - Remember a UPnP control point to send events to.
* @sm: WPS UPnP state machine from upnp_wps_device_init() * @sm: WPS UPnP state machine from upnp_wps_device_init()
* @callback_urls: malloc' mem given to the subscription * @callback_urls: Callback URLs
* Returns: %NULL on error, or pointer to new subscription structure. * Returns: %NULL on error, or pointer to new subscription structure.
*/ */
struct subscription * subscription_start(struct upnp_wps_device_sm *sm, struct subscription * subscription_start(struct upnp_wps_device_sm *sm,
char *callback_urls) const char *callback_urls)
{ {
struct subscription *s; struct subscription *s;
time_t now = time(NULL); time_t now = time(NULL);
@ -780,7 +780,6 @@ struct subscription * subscription_start(struct upnp_wps_device_sm *sm,
} }
wpa_printf(MSG_DEBUG, "WPS UPnP: Subscription %p started with %s", wpa_printf(MSG_DEBUG, "WPS UPnP: Subscription %p started with %s",
s, callback_urls); s, callback_urls);
os_free(callback_urls);
/* Schedule sending this */ /* Schedule sending this */
event_send_all_later(sm); event_send_all_later(sm);
return s; return s;

View file

@ -145,7 +145,7 @@ struct upnp_wps_device_sm {
/* wps_upnp.c */ /* wps_upnp.c */
void format_date(struct wpabuf *buf); void format_date(struct wpabuf *buf);
struct subscription * subscription_start(struct upnp_wps_device_sm *sm, struct subscription * subscription_start(struct upnp_wps_device_sm *sm,
char *callback_urls); const char *callback_urls);
struct subscription * subscription_renew(struct upnp_wps_device_sm *sm, struct subscription * subscription_renew(struct upnp_wps_device_sm *sm,
const u8 uuid[UUID_LEN]); const u8 uuid[UUID_LEN]);
void subscription_unlink(struct subscription *s); void subscription_unlink(struct subscription *s);

View file

@ -925,7 +925,6 @@ static void web_connection_parse_subscribe(struct upnp_wps_device_sm *sm,
ret = HTTP_INTERNAL_SERVER_ERROR; ret = HTTP_INTERNAL_SERVER_ERROR;
goto error; goto error;
} }
callback_urls = NULL; /* is now owned by subscription */
} else { } else {
ret = HTTP_PRECONDITION_FAILED; ret = HTTP_PRECONDITION_FAILED;
goto error; goto error;
@ -975,6 +974,7 @@ error:
*/ */
http_put_empty(buf, ret); http_put_empty(buf, ret);
http_request_send_and_deinit(req, buf); http_request_send_and_deinit(req, buf);
os_free(callback_urls);
} }