diff --git a/ChangeLog b/ChangeLog index 7bfbf32..8e6dd9e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -349,6 +349,13 @@ Version 1.8.0 Version 1.6.19 ******************************************************************************* +2013-07-30 Zheng Peng + + SF ticket #116 UpnpRemoveVirtualDir wrong linked list operation + + What if pVirtualDirList has two nodes and what we want to delete is the + first one. Patch attached. + 2013-07-30 Sebastian Brandt Dear libupnp-devels, diff --git a/THANKS b/THANKS index d592ab4..d73ff23 100644 --- a/THANKS +++ b/THANKS @@ -69,4 +69,5 @@ exempt of errors. - Tom (tomdev2) - Yoichi Nakayama (yoichi) - zephyrus (zephyrus00jp) +- Zheng Peng (darkelf2010) diff --git a/upnp/src/api/upnpapi.c b/upnp/src/api/upnpapi.c index 82e73a8..92147f8 100644 --- a/upnp/src/api/upnpapi.c +++ b/upnp/src/api/upnpapi.c @@ -4187,16 +4187,17 @@ int UpnpRemoveVirtualDir(const char *dirName) return UPNP_E_INVALID_PARAM; } /* Handle the special case where the directory that we are */ - /* removing is the first and only one in the list. */ - if( ( pVirtualDirList->next == NULL ) && - ( strcmp( pVirtualDirList->dirName, dirName ) == 0 ) ) { - free( pVirtualDirList ); - pVirtualDirList = NULL; + /* removing is the first in the list. */ + if (strcmp( pVirtualDirList->dirName, dirName ) == 0) + { + pPrev = pVirtualDirList; + pVirtualDirList = pVirtualDirList->next; + free( pPrev ); return UPNP_E_SUCCESS; } - pCur = pVirtualDirList; - pPrev = pCur; + pCur = pVirtualDirList->next; + pPrev = pVirtualDirList; while( pCur != NULL ) { if( strcmp( pCur->dirName, dirName ) == 0 ) {