]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
gnutls_priority_init: set err_pos prior to any action
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Tue, 22 Jul 2014 11:19:15 +0000 (13:19 +0200)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Tue, 22 Jul 2014 11:19:17 +0000 (13:19 +0200)
That allows a valid err_pos, even on a memory allocation
error. Reported by Dan Fandrich.

lib/gnutls_priority.c

index 916ce850e490b73621378271770e8147bd067a45..5c8b7aa359ee6bcd14ad3e80df6ee7fd65231823 100644 (file)
@@ -1018,7 +1018,7 @@ finish:
  * gnutls_priority_init:
  * @priority_cache: is a #gnutls_prioritity_t structure.
  * @priorities: is a string describing priorities
- * @err_pos: In case of an error this will have the position in the string the error occured
+ * @err_pos: In case of an error this will have the position in the string the error occurred
  *
  * Sets priorities for the ciphers, key exchange methods, macs and
  * compression methods.
@@ -1111,6 +1111,9 @@ gnutls_priority_init(gnutls_priority_t * priority_cache,
        rmadd_func *fn;
        bulk_rmadd_func *bulk_fn;
 
+       if (err_pos)
+               *err_pos = priorities;
+
        *priority_cache =
            gnutls_calloc(1, sizeof(struct gnutls_priority_st));
        if (*priority_cache == NULL) {
@@ -1118,9 +1121,6 @@ gnutls_priority_init(gnutls_priority_t * priority_cache,
                return GNUTLS_E_MEMORY_ERROR;
        }
 
-       if (err_pos)
-               *err_pos = priorities;
-
        /* for now unsafe renegotiation is default on everyone. To be removed
         * when we make it the default.
         */