]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
more leaks fixed in common.c
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Fri, 8 Apr 2011 15:17:24 +0000 (17:17 +0200)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Fri, 8 Apr 2011 15:17:24 +0000 (17:17 +0200)
lib/x509/common.c

index 21774dfaee85c69e9206d2275b30c22f7eb7e1b3..51dc97aa0475e0f941725e1d8ca138e3d7339306 100644 (file)
@@ -1112,14 +1112,6 @@ _gnutls_x509_write_value (ASN1_TYPE c, const char *root,
     {
       /* Convert it to OCTET STRING
        */
-      val.data = gnutls_malloc (asize);
-      if (val.data == NULL)
-        {
-          gnutls_assert ();
-          result = GNUTLS_E_MEMORY_ERROR;
-          goto cleanup;
-        }
-
       if ((result = asn1_create_element
            (_gnutls_get_pkix (), "PKIX1.pkcs-7-Data", &c2)) != ASN1_SUCCESS)
         {
@@ -1153,19 +1145,17 @@ _gnutls_x509_write_value (ASN1_TYPE c, const char *root,
   /* Write the data.
    */
   result = asn1_write_value (c, root, val.data, val.size);
-
-  if (val.data != data->data)
-    _gnutls_free_datum (&val);
-
   if (result != ASN1_SUCCESS)
     {
       gnutls_assert ();
-      return _gnutls_asn2err (result);
+      result = _gnutls_asn2err (result);
+      goto cleanup;
     }
 
-  return 0;
+  result = 0;
 
 cleanup:
+  asn1_delete_structure (&c2);
   if (val.data != data->data)
     _gnutls_free_datum (&val);
   return result;