asn1/tasn_utl.c: fix logical error in asn1_do_lock.
authorAndy Polyakov <appro@openssl.org>
Thu, 2 Aug 2018 07:02:47 +0000 (09:02 +0200)
committerAndy Polyakov <appro@openssl.org>
Fri, 3 Aug 2018 07:01:08 +0000 (09:01 +0200)
CRYPTO_atomic_add was assumed to return negative value on error, while
it returns 0.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/6843)

crypto/asn1/tasn_utl.c

index f79d7d6b447cf2ed5d3eb19ebbbfedcd0c8495f3..cad45a07f52dbf69f1654568ce01590d4c47032c 100644 (file)
@@ -76,7 +76,7 @@ int asn1_do_lock(ASN1_VALUE **pval, int op, const ASN1_ITEM *it)
         }
         return 1;
     }
-    if (CRYPTO_atomic_add(lck, op, &ret, *lock) < 0)
+    if (!CRYPTO_atomic_add(lck, op, &ret, *lock))
         return -1;  /* failed */
 #ifdef REF_PRINT
     fprintf(stderr, "%p:%4d:%s\n", it, *lck, it->sname);