Put the first stage of my bignum debugging adventures into CVS. This code
[openssl.git] / crypto / bn / bn_ctx.c
index a0e7915fb91f0aafe392ebac980b42df9f49d2b8..7b5be7c43528d63cd587f8e5d5522b6e3cea125d 100644 (file)
@@ -121,8 +121,10 @@ void BN_CTX_free(BN_CTX *ctx)
        if (ctx == NULL) return;
        assert(ctx->depth == 0);
 
-       for (i=0; i < BN_CTX_NUM; i++)
+       for (i=0; i < BN_CTX_NUM; i++) {
+               bn_check_top(&(ctx->bn[i]));
                BN_clear_free(&(ctx->bn[i]));
+       }
        if (ctx->flags & BN_FLG_MALLOCED)
                OPENSSL_free(ctx);
        }
@@ -152,6 +154,7 @@ BIGNUM *BN_CTX_get(BN_CTX *ctx)
                        }
                return NULL;
                }
+       bn_check_top(&(ctx->bn[ctx->tos]));
        return (&(ctx->bn[ctx->tos++]));
        }