OSDN Git Service

Don't leak memory on failed pipe or mutex init
authorKenny Root <kroot@google.com>
Thu, 25 Mar 2010 00:01:22 +0000 (17:01 -0700)
committerKenny Root <kroot@google.com>
Thu, 25 Mar 2010 00:01:22 +0000 (17:01 -0700)
SSL allocation might fail on pipe or mutex creation, so free allocated
memory when that happens.

Change-Id: Ibe3813cb652db1e880e3acf0dc1fa37fbe0ad455

libcore/x-net/src/main/native/org_apache_harmony_xnet_provider_jsse_NativeCrypto.cpp

index 407ca0d..6319bbf 100644 (file)
@@ -736,10 +736,12 @@ static int sslCreateAppData(SSL* ssl) {
     data->fdsEmergency[1] = -1;
 
     if (pipe(data->fdsEmergency) == -1) {
+        free(data);
         return -1;
     }
 
     if (MUTEX_SETUP(data->mutex) == -1) {
+        free(data);
         return -1;
     }