diff --git a/ChangeLog b/ChangeLog index 6f72468..32a6d93 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,10 @@ Version 1.8.0 ******************************************************************************* +2010-03-27 Marcelo Jimenez + Protect the object destructors agains null pointers on deletion, which + should be something valid. + 2010-03-27 Marcelo Jimenez SF Patch Tracker [ 2987390 ] upnp_debug vs. ixml_debug Thanks for the load of updates, I'm still assimilating them ! Could I make diff --git a/upnp/src/api/ActionComplete.c b/upnp/src/api/ActionComplete.c index 63f122b..bb5529d 100644 --- a/upnp/src/api/ActionComplete.c +++ b/upnp/src/api/ActionComplete.c @@ -56,6 +56,8 @@ void UpnpActionComplete_delete(UpnpActionComplete *p) { struct SUpnpActionComplete *q = (struct SUpnpActionComplete *)p; + if (!q) return; + q->m_errCode = 0; UpnpString_delete(q->m_ctrlUrl); diff --git a/upnp/src/api/ActionRequest.c b/upnp/src/api/ActionRequest.c index b45b5e6..7b6a75b 100644 --- a/upnp/src/api/ActionRequest.c +++ b/upnp/src/api/ActionRequest.c @@ -62,6 +62,8 @@ void UpnpActionRequest_delete(UpnpActionRequest *p) { struct SUpnpActionRequest *q = (struct SUpnpActionRequest *)p; + if (!q) return; + q->m_errCode = 0; q->m_socket = 0; diff --git a/upnp/src/api/Discovery.c b/upnp/src/api/Discovery.c index 84d3eb8..c971604 100644 --- a/upnp/src/api/Discovery.c +++ b/upnp/src/api/Discovery.c @@ -63,6 +63,8 @@ void UpnpDiscovery_delete(UpnpDiscovery *p) { struct SUpnpDiscovery *q = (struct SUpnpDiscovery *)p; + if (!q) return; + q->m_errCode = 0; q->m_expires = 0; diff --git a/upnp/src/api/Event.c b/upnp/src/api/Event.c index 009edbe..9ba0118 100644 --- a/upnp/src/api/Event.c +++ b/upnp/src/api/Event.c @@ -44,6 +44,8 @@ void UpnpEvent_delete(UpnpEvent *p) { struct SUpnpEvent *q = (struct SUpnpEvent *)p; + if (!q) return; + q->m_eventKey = 0; q->m_changedVariables = NULL; diff --git a/upnp/src/api/EventSubscribe.c b/upnp/src/api/EventSubscribe.c index 6be00be..556166c 100644 --- a/upnp/src/api/EventSubscribe.c +++ b/upnp/src/api/EventSubscribe.c @@ -45,6 +45,8 @@ void UpnpEventSubscribe_delete(UpnpEventSubscribe *p) { struct SEventSubscribe *q = (struct SEventSubscribe *)p; + if (!q) return; + q->m_errCode = 0; q->m_timeOut = 0; diff --git a/upnp/src/api/FileInfo.c b/upnp/src/api/FileInfo.c index dc64166..be2054f 100644 --- a/upnp/src/api/FileInfo.c +++ b/upnp/src/api/FileInfo.c @@ -51,6 +51,8 @@ void UpnpFileInfo_delete(UpnpFileInfo *p) { struct SUpnpFileInfo *q = (struct SUpnpFileInfo *)p; + if (!q) return; + q->m_fileLength = 0; q->m_lastModified = 0; diff --git a/upnp/src/api/StateVarComplete.c b/upnp/src/api/StateVarComplete.c index 58c9b3a..a1fd86a 100644 --- a/upnp/src/api/StateVarComplete.c +++ b/upnp/src/api/StateVarComplete.c @@ -49,6 +49,8 @@ void UpnpStateVarComplete_delete(UpnpStateVarComplete *p) { struct SUpnpStateVarComplete *q = (struct SUpnpStateVarComplete *)p; + if (!q) return; + q->m_errCode = 0; UpnpString_delete(q->m_ctrlUrl); diff --git a/upnp/src/api/StateVarRequest.c b/upnp/src/api/StateVarRequest.c index 4b79787..3fdcba9 100644 --- a/upnp/src/api/StateVarRequest.c +++ b/upnp/src/api/StateVarRequest.c @@ -59,6 +59,8 @@ void UpnpStateVarRequest_delete(UpnpStateVarRequest *p) { struct SUpnpStateVarRequest *q = (struct SUpnpStateVarRequest *)p; + if (!q) return; + q->m_errCode = 0; q->m_socket = 0; diff --git a/upnp/src/api/SubscriptionRequest.c b/upnp/src/api/SubscriptionRequest.c index c77cc3d..2c98b26 100644 --- a/upnp/src/api/SubscriptionRequest.c +++ b/upnp/src/api/SubscriptionRequest.c @@ -43,6 +43,8 @@ void UpnpSubscriptionRequest_delete(UpnpSubscriptionRequest *p) { struct SUpnpSubscriptionRequest *q = (struct SUpnpSubscriptionRequest *)p; + if (!q) return; + UpnpString_delete(q->m_serviceId); q->m_serviceId = NULL; diff --git a/upnp/src/api/UpnpString.c b/upnp/src/api/UpnpString.c index 197ece9..baba49d 100644 --- a/upnp/src/api/UpnpString.c +++ b/upnp/src/api/UpnpString.c @@ -74,6 +74,8 @@ void UpnpString_delete(UpnpString *p) { struct SUpnpString *q = (struct SUpnpString *)p; + if (!q) return; + q->m_length = 0; free(q->m_string); diff --git a/upnp/src/genlib/client_table/client_table.c b/upnp/src/genlib/client_table/client_table.c index 17167b1..4f8bd2c 100644 --- a/upnp/src/genlib/client_table/client_table.c +++ b/upnp/src/genlib/client_table/client_table.c @@ -79,6 +79,8 @@ void UpnpClientSubscription_delete(ClientSubscription *p) { struct SClientSubscription *q = (struct SClientSubscription *)p; + if (!q) return; + q->m_renewEventId = 0; UpnpString_delete(q->m_SID); diff --git a/upnp/src/genlib/util/membuffer.c b/upnp/src/genlib/util/membuffer.c index bed1a61..3224fda 100644 --- a/upnp/src/genlib/util/membuffer.c +++ b/upnp/src/genlib/util/membuffer.c @@ -1,33 +1,33 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2000-2003 Intel Corporation -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// * Neither name of Intel Corporation nor the names of its contributors -// may be used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY -// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////// +/******************************************************************************* + * + * Copyright (c) 2000-2003 Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither name of Intel Corporation nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + ******************************************************************************/ /************************************************************************ * Purpose: This file contains functions that operate on memory and @@ -491,6 +491,8 @@ membuffer_delete( INOUT membuffer * m, assert( m != NULL ); + if (!m) return; + if( m->length == 0 ) { return; }