fix memory leak in err.c
authorBodo Möller <bodo@openssl.org>
Mon, 12 Mar 2001 18:07:20 +0000 (18:07 +0000)
committerBodo Möller <bodo@openssl.org>
Mon, 12 Mar 2001 18:07:20 +0000 (18:07 +0000)
CHANGES
crypto/err/err.c

diff --git a/CHANGES b/CHANGES
index 8ed1b986338850e29d09c0b617d38024ad3a59f5..4c8a93cb1b96578515cec04ba6f02a447c715680 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -3,6 +3,9 @@
 
  Changes between 0.9.6 and 0.9.7  [xx XXX 2000]
 
+  *) Fix a memory leak in err.c: free err_data string if necessary.
+     [Bodo Moeller]
+
   *) Function EC_POINTs_mul for simultaneous scalar multiplication
      of an arbitrary number of elliptic curve points, optionally
      including the generator defined for the EC_GROUP.
index 145fdc58d186ddb9d2b6f0b98cd426e2c76f2e69..91b0295fb5ec0eea730a035765dde76ed3650429 100644 (file)
@@ -466,7 +466,15 @@ static unsigned long get_error_values(int inc, const char **file, int *line,
                        }
                }
 
-       if (data != NULL)
+       if (data == NULL)
+               {
+               if (inc && (es->err_data[i] != NULL) && (es->err_data_flags[i] & ERR_TXT_MALLOCED))
+                       {
+                       OPENSSL_free(es->err_data[i]);
+                       es->err_data[i] = NULL;
+                       }
+               }
+       else
                {
                if (es->err_data[i] == NULL)
                        {