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.
(cherry picked from commit 907c7c2621)
This commit is contained in:
Zheng Peng 2013-07-30 16:02:14 -03:00 committed by Marcelo Roberto Jimenez
parent 97b6be674a
commit a641a27cb6
3 changed files with 16 additions and 7 deletions

View File

@ -349,6 +349,13 @@ Version 1.8.0
Version 1.6.19
*******************************************************************************
2013-07-30 Zheng Peng <darkelf2010(at)users.sf.net>
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 <s.brandt(at)aixtrusion.de>
Dear libupnp-devels,

1
THANKS
View File

@ -69,4 +69,5 @@ exempt of errors.
- Tom (tomdev2)
- Yoichi Nakayama (yoichi)
- zephyrus (zephyrus00jp)
- Zheng Peng (darkelf2010)

View File

@ -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 ) {