Bugzilla Bug 337637: fixed a memory leak on error in _MD_OpenSharedMemory. NSPRPUB_PRE_4_2_CLIENT_BRANCH
authorwtchang%redhat.com
Tue, 12 Sep 2006 18:01:17 +0000
branchNSPRPUB_PRE_4_2_CLIENT_BRANCH
changeset 3692 e60b707c5a4dcbdd0f927b8f60be9588c2300ddd
parent 3690 595fae0b72aa1097324b3014ae192354106242c9
child 3694 73d88fc3c5c551b6ab0339f0a1c7de137062a5cf
push idunknown
push userunknown
push dateunknown
bugs337637
Bugzilla Bug 337637: fixed a memory leak on error in _MD_OpenSharedMemory. The patch is contributed by Bruno 'Aqualon' Escherl <aqualon@aquachan.de>. r=wtc. Tag: NSPRPUB_PRE_4_2_CLIENT_BRANCH
pr/src/md/unix/uxshm.c
--- a/pr/src/md/unix/uxshm.c
+++ b/pr/src/md/unix/uxshm.c
@@ -97,16 +97,17 @@ extern PRSharedMemory * _MD_OpenSharedMe
         return( NULL );
     }
 
     shm->ipcname = (char*)PR_MALLOC( strlen( ipcname ) + 1 );
     if ( NULL == shm->ipcname )
     {
         PR_SetError(PR_OUT_OF_MEMORY_ERROR, 0 );
         PR_LOG(_pr_shm_lm, PR_LOG_DEBUG, ( "PR_OpenSharedMemory: New shm->ipcname out of memory")); 
+        PR_DELETE( shm );
         return( NULL );
     }
 
     /* copy args to struct */
     strcpy( shm->ipcname, ipcname );
     shm->size = size; 
     shm->mode = mode; 
     shm->flags = flags;