chantra / rpms / tpm2-tss

Forked from rpms/tpm2-tss 2 years ago
Clone

Blame SOURCES/Fix-memory-leaks-on-error-conditions-in-InitSysConte.patch

03cf90
diff -ur TPM2.0-TSS-1.0/common/syscontext.c TPM2.0-TSS-1.0-new/common/syscontext.c
03cf90
--- TPM2.0-TSS-1.0/common/syscontext.c	2016-11-01 06:53:15.000000000 -0700
03cf90
+++ TPM2.0-TSS-1.0-new/common/syscontext.c	2017-04-02 16:36:47.603294296 -0700
03cf90
@@ -58,10 +58,12 @@
03cf90
         // Initialized the system context structure.
03cf90
         rval = Tss2_Sys_Initialize( sysContext, contextSize, tctiContext, abiVersion );
03cf90
 
03cf90
-        if( rval == TSS2_RC_SUCCESS )
03cf90
+        if( rval == TSS2_RC_SUCCESS ) {
03cf90
             return sysContext;
03cf90
-        else
03cf90
-            return 0;
03cf90
+        } else {
03cf90
+	    free (sysContext);
03cf90
+            return NULL;
03cf90
+	}
03cf90
     }
03cf90
     else
03cf90
     {
03cf90
diff -ur TPM2.0-TSS-1.0/resourcemgr/resourcemgr.c TPM2.0-TSS-1.0-new/resourcemgr/resourcemgr.c
03cf90
--- TPM2.0-TSS-1.0/resourcemgr/resourcemgr.c	2016-11-01 06:53:15.000000000 -0700
03cf90
+++ TPM2.0-TSS-1.0-new/resourcemgr/resourcemgr.c	2017-04-02 16:36:47.604294312 -0700
03cf90
@@ -2708,6 +2708,7 @@
03cf90
         if( cmdServerStruct->connectSock == INVALID_SOCKET )
03cf90
         {
03cf90
             printf( "Accept failed.  Error is 0x%x\n", WSAGetLastError() );
03cf90
+	    (*rmFree)( cmdServerStruct );
03cf90
             continue;
03cf90
         }
03cf90
 
03cf90
@@ -2752,6 +2753,7 @@
03cf90
     if( 0 == strcmp( &otherCmdStr[0], serverStruct->serverName ) )
03cf90
     {
03cf90
         printf( "SockServer died (%s), socket: 0x%x.\n", serverStruct->serverName, serverStruct->connectSock );
03cf90
+	(*rmFree)( cmdServerStruct );
03cf90
         ExitThread( 0 );
03cf90
     }
03cf90