Avoid creating an illegal pointer
authorKurt Roeckx <kurt@roeckx.be>
Mon, 23 May 2016 21:09:33 +0000 (23:09 +0200)
committerKurt Roeckx <kurt@roeckx.be>
Tue, 24 May 2016 19:33:02 +0000 (21:33 +0200)
Found by tis-interpreter

Reviewed-by: Richard Levitte <levitte@openssl.org>
GH: #1115

crypto/asn1/tasn_fre.c

index 1471680..9b623d9 100644 (file)
@@ -102,9 +102,11 @@ static void asn1_item_embed_free(ASN1_VALUE **pval, const ASN1_ITEM *it,
          * field and we wont be able to determine the type of the field it
          * defines. So free up in reverse order.
          */
-        tt = it->templates + it->tcount - 1;
-        for (i = 0; i < it->tcount; tt--, i++) {
+        tt = it->templates + it->tcount;
+        for (i = 0; i < it->tcount; i++) {
             ASN1_VALUE **pseqval;
+
+            tt--;
             seqtt = asn1_do_adb(pval, tt, 0);
             if (!seqtt)
                 continue;