#2 lib: Clean up potential memory leak
Merged 6 years ago by yunyings. Opened 6 years ago by snits.
rpms/ snits/tpm2-tools memleak  into  master

@@ -0,0 +1,31 @@ 

+ From 5b84837757cab93397cfa5830e69d2b7e7ce0e0c Mon Sep 17 00:00:00 2001

+ From: Jerry Snitselaar <jsnitsel@redhat.com>

+ Date: Wed, 18 Oct 2017 21:46:45 -0700

+ Subject: [PATCH] lib: clean up potential memory leak

+ 

+ In case where sapi_ctx_init fails in sapi_init_from_options, free tcti_ctx.

+ 

+ Signed-off-by: Jerry Snitselaar <jsnitsel@redhat.com>

+ ---

+  lib/context-util.c | 4 +++-

+  1 file changed, 3 insertions(+), 1 deletion(-)

+ 

+ diff --git a/lib/context-util.c b/lib/context-util.c

+ index 7de22ac..c3034f9 100644

+ --- a/lib/context-util.c

+ +++ b/lib/context-util.c

+ @@ -205,8 +205,10 @@ sapi_init_from_options (common_opts_t *options)

+      if (tcti_ctx == NULL)

+          return NULL;

+      sapi_ctx = sapi_ctx_init (tcti_ctx);

+ -    if (sapi_ctx == NULL)

+ +    if (sapi_ctx == NULL) {

+ +        free (tcti_ctx);

+          return NULL;

+ +    }

+      return sapi_ctx;

+  }

+  /*

+ -- 

+ 2.15.0.rc0

+ 

file modified
+6 -1
@@ -1,6 +1,6 @@ 

  Name: tpm2-tools

  Version: 2.1.0 

- Release: 6%{?dist}

+ Release: 7%{?dist}

  Summary: A TPM2.0 testing tool build upon TPM2.0-TSS

  

  %global pkg_prefix tpm2.0-tools
@@ -13,6 +13,8 @@ 

  Patch0: gcc7-implict-fallthrough-fix.patch

  # https://github.com/01org/tpm2-tools/commit/5cee30cbc3da

  Patch1: allow-to-build-with-openssl-1.1.x.patch

+ # https://github.com/01org/tpm2-tools/pull/567

+ Patch2: 0001-lib-clean-up-potential-memory-leak.patch

  

  BuildRequires: gcc-c++

  BuildRequires: libtool
@@ -54,6 +56,9 @@ 

  %{_mandir}/man8/tpm2_*.8.gz

  

  %changelog

+ * Thu Oct 19 2017 Jerry Snitselaar <jsnitsel@redhat.com> - 2.1.0-7

+ - Clean up potential memleak (RHBZ#1503959)

+ 

  * Thu Oct 05 2017 Javier Martinez Canillas <javierm@redhat.com> - 2.1.0-6

  - Add tpm2-abrmd-devel BuildRequires so tools have abrmd support (RHBZ#1498909)

  

If sapi_ctx_init fails, free tcti_ctx

resolves: rhbz#1503959

Signed-off-by: Jerry Snitselaar jsnitsel@redhat.com

This was another coverity scan issue.

Pull-Request has been merged by yunyings

6 years ago