test/ectest.c:2075: error: INTEGER_OVERFLOW_L2
  ([0, +oo] - 1):unsigned32 by call to `BN_CTX_end`.
Showing all 8 steps of the trace


test/ectest.c:1912:5: Call
1910.       if (!TEST_ptr(bn_ctx = BN_CTX_new()))
1911.           return ret;
1912.       BN_CTX_start(bn_ctx);
            ^
1913.   
1914.       if (/* Allocations */

crypto/bn/bn_ctx.c:194:1: Parameter `ctx->stack.depth`
  192.   }
  193.   
  194. > void BN_CTX_start(BN_CTX *ctx)
  195.   {
  196.       CTXDBG("ENTER BN_CTX_start()", ctx);

test/ectest.c:2075:5: Call
2073.       EC_GROUP_free(tmpg);
2074.       EC_GROUP_free(group);
2075.       BN_CTX_end(bn_ctx);
            ^
2076.       BN_CTX_free(bn_ctx);
2077.       return ret;

crypto/bn/bn_ctx.c:208:1: Parameter `ctx->stack.depth`
  206.   }
  207.   
  208. > void BN_CTX_end(BN_CTX *ctx)
  209.   {
  210.       if (ctx == NULL)

crypto/bn/bn_ctx.c:216:27: Call
  214.           ctx->err_stack--;
  215.       else {
  216.           unsigned int fp = BN_STACK_pop(&ctx->stack);
                                   ^
  217.           /* Does this stack frame have anything to release? */
  218.           if (fp < ctx->used)

crypto/bn/bn_ctx.c:298:1: <LHS trace>
296.   }
297.   
298. > static unsigned int BN_STACK_pop(BN_STACK *st)
299.   {
300.       return st->indexes[--(st->depth)];

crypto/bn/bn_ctx.c:298:1: Parameter `st->depth`
    296.   }
    297.   
    298. > static unsigned int BN_STACK_pop(BN_STACK *st)
    299.   {
    300.       return st->indexes[--(st->depth)];

crypto/bn/bn_ctx.c:300:12: Binary operation: ([0, +oo] - 1):unsigned32 by call to `BN_CTX_end` 
    298.   static unsigned int BN_STACK_pop(BN_STACK *st)
    299.   {
    300.       return st->indexes[--(st->depth)];
                      ^
    301.   }
    302.   

static unsigned int BN_STACK_pop(BN_STACK *st)
{
    return st->indexes[--(st->depth)];
}
['static int check_named_curve_from_ecparameters(int id)\n{\n    int ret = 0, nid, tnid;\n    EC_GROUP *group = NULL, *tgroup = NULL, *tmpg = NULL;\n    const EC_POINT *group_gen = NULL;\n    EC_POINT *other_gen = NULL;\n    BIGNUM *group_cofactor = NULL, *other_cofactor = NULL;\n    BIGNUM *other_gen_x = NULL, *other_gen_y = NULL;\n    const BIGNUM *group_order = NULL;\n    BIGNUM *other_order = NULL;\n    BN_CTX *bn_ctx = NULL;\n    static const unsigned char invalid_seed[] = "THIS IS NOT A VALID SEED";\n    static size_t invalid_seed_len = sizeof(invalid_seed);\n    ECPARAMETERS *params = NULL, *other_params = NULL;\n    EC_GROUP *g_ary[8] = {NULL};\n    EC_GROUP **g_next = &g_ary[0];\n    ECPARAMETERS *p_ary[8] = {NULL};\n    ECPARAMETERS **p_next = &p_ary[0];\n    nid = curves[id].nid;\n    TEST_note("Curve %s", OBJ_nid2sn(nid));\n    if (!TEST_ptr(bn_ctx = BN_CTX_new()))\n        return ret;\n    BN_CTX_start(bn_ctx);\n    if (\n        !TEST_ptr(group_cofactor = BN_CTX_get(bn_ctx))\n        || !TEST_ptr(other_gen_x = BN_CTX_get(bn_ctx))\n        || !TEST_ptr(other_gen_y = BN_CTX_get(bn_ctx))\n        || !TEST_ptr(other_order = BN_CTX_get(bn_ctx))\n        || !TEST_ptr(other_cofactor = BN_CTX_get(bn_ctx))\n        || !TEST_ptr(group = EC_GROUP_new_by_curve_name(nid))\n        || !TEST_ptr(params = EC_GROUP_get_ecparameters(group, NULL))\n        || !TEST_ptr(group_gen = EC_GROUP_get0_generator(group))\n        || !TEST_ptr(group_order = EC_GROUP_get0_order(group))\n        || !TEST_true(EC_GROUP_get_cofactor(group, group_cofactor, NULL))\n        || !TEST_ptr(tmpg = EC_GROUP_dup(group))\n        || !TEST_ptr(other_gen = EC_POINT_dup(group_gen, group))\n        || !TEST_true(EC_POINT_add(group, other_gen, group_gen, group_gen, NULL))\n        || !TEST_true(EC_POINT_get_affine_coordinates(group, other_gen,\n                      other_gen_x, other_gen_y, bn_ctx))\n        || !TEST_true(BN_copy(other_order, group_order))\n        || !TEST_true(BN_add_word(other_order, 1))\n        || !TEST_true(BN_copy(other_cofactor, group_cofactor))\n        || !TEST_true(BN_add_word(other_cofactor, 1)))\n        goto err;\n    EC_POINT_free(other_gen);\n    other_gen = NULL;\n    if (!TEST_ptr(other_gen = EC_POINT_new(tmpg))\n        || !TEST_true(EC_POINT_set_affine_coordinates(tmpg, other_gen,\n                                                      other_gen_x, other_gen_y,\n                                                      bn_ctx)))\n        goto err;\n    if (!TEST_ptr(tgroup = *g_next++ = EC_GROUP_new_from_ecparameters(params))\n        || !TEST_int_ne((tnid = EC_GROUP_get_curve_name(tgroup)), NID_undef))\n        goto err;\n    if (!TEST_true(are_ec_nids_compatible(nid, tnid))) {\n        TEST_info("nid = %s, tnid = %s", OBJ_nid2sn(nid), OBJ_nid2sn(tnid));\n        goto err;\n    }\n    if (!TEST_int_eq(EC_GROUP_get_asn1_flag(tgroup), OPENSSL_EC_EXPLICIT_CURVE))\n        goto err;\n    if (!TEST_int_eq(EC_GROUP_set_seed(tmpg, invalid_seed, invalid_seed_len),\n                     invalid_seed_len)\n            || !TEST_ptr(other_params = *p_next++ =\n                         EC_GROUP_get_ecparameters(tmpg, NULL))\n            || !TEST_ptr(tgroup = *g_next++ =\n                          EC_GROUP_new_from_ecparameters(other_params))\n            || !TEST_int_ne((tnid = EC_GROUP_get_curve_name(tgroup)), NID_undef)\n            || !TEST_true(are_ec_nids_compatible(nid, tnid))\n            || !TEST_int_eq(EC_GROUP_get_asn1_flag(tgroup),\n                            OPENSSL_EC_EXPLICIT_CURVE)) {\n        TEST_info("nid = %s, tnid = %s", OBJ_nid2sn(nid), OBJ_nid2sn(tnid));\n        goto err;\n    }\n    if (!TEST_int_eq(EC_GROUP_set_seed(tmpg, NULL, 0), 1)\n            || !TEST_ptr(other_params = *p_next++ =\n                         EC_GROUP_get_ecparameters(tmpg, NULL))\n            || !TEST_ptr(tgroup = *g_next++ =\n                          EC_GROUP_new_from_ecparameters(other_params))\n            || !TEST_int_ne((tnid = EC_GROUP_get_curve_name(tgroup)), NID_undef)\n            || !TEST_true(are_ec_nids_compatible(nid, tnid))\n            || !TEST_int_eq(EC_GROUP_get_asn1_flag(tgroup),\n                            OPENSSL_EC_EXPLICIT_CURVE)) {\n        TEST_info("nid = %s, tnid = %s", OBJ_nid2sn(nid), OBJ_nid2sn(tnid));\n        goto err;\n    }\n    if (\n        !TEST_true(EC_GROUP_set_generator(tmpg, other_gen, group_order,\n                                          group_cofactor))\n        || !TEST_ptr(other_params = *p_next++ =\n                     EC_GROUP_get_ecparameters(tmpg, NULL))\n        || !TEST_ptr(tgroup = *g_next++ =\n                      EC_GROUP_new_from_ecparameters(other_params))\n        || !TEST_int_eq((tnid = EC_GROUP_get_curve_name(tgroup)), NID_undef)\n        || !TEST_true(EC_GROUP_set_generator(tmpg, group_gen, other_order,\n                                             group_cofactor))\n        || !TEST_ptr(other_params = *p_next++ =\n                     EC_GROUP_get_ecparameters(tmpg, NULL))\n        || !TEST_ptr(tgroup = *g_next++ =\n                      EC_GROUP_new_from_ecparameters(other_params))\n        || !TEST_int_eq((tnid = EC_GROUP_get_curve_name(tgroup)), NID_undef)\n        || !TEST_false(EC_GROUP_set_generator(tmpg, group_gen, NULL,\n                                              group_cofactor))\n        || !TEST_true(EC_GROUP_set_generator(tmpg, group_gen, group_order,\n                                             other_cofactor))\n        || !TEST_ptr(other_params = *p_next++ =\n                     EC_GROUP_get_ecparameters(tmpg, NULL))\n        || !TEST_ptr(tgroup = *g_next++ =\n                      EC_GROUP_new_from_ecparameters(other_params))\n        || !TEST_int_ne((tnid = EC_GROUP_get_curve_name(tgroup)), NID_undef)\n        || !TEST_true(are_ec_nids_compatible(nid, tnid))\n        || !TEST_int_eq(EC_GROUP_get_asn1_flag(tgroup),\n                        OPENSSL_EC_EXPLICIT_CURVE)\n        || !TEST_true(EC_GROUP_set_generator(tmpg, group_gen, group_order,\n                                             NULL))\n        || !TEST_ptr(other_params = *p_next++ =\n                     EC_GROUP_get_ecparameters(tmpg, NULL))\n        || !TEST_ptr(tgroup = *g_next++ =\n                      EC_GROUP_new_from_ecparameters(other_params))\n        || !TEST_int_ne((tnid = EC_GROUP_get_curve_name(tgroup)), NID_undef)\n        || !TEST_true(are_ec_nids_compatible(nid, tnid))\n        || !TEST_int_eq(EC_GROUP_get_asn1_flag(tgroup),\n                        OPENSSL_EC_EXPLICIT_CURVE)\n        || !TEST_true(EC_GROUP_set_generator(tmpg, group_gen, group_order,\n                                             group_cofactor))\n        || !TEST_ptr(other_params = *p_next++ =\n                     EC_GROUP_get_ecparameters(tmpg, NULL))\n        || !TEST_ptr(tgroup = *g_next++ =\n                      EC_GROUP_new_from_ecparameters(other_params))\n        || !TEST_int_ne((tnid = EC_GROUP_get_curve_name(tgroup)), NID_undef)\n        || !TEST_true(are_ec_nids_compatible(nid, tnid))\n        || !TEST_int_eq(EC_GROUP_get_asn1_flag(tgroup),\n                        OPENSSL_EC_EXPLICIT_CURVE))\n        goto err;\n    ret = 1;\nerr:\n    for (g_next = &g_ary[0]; g_next < g_ary + OSSL_NELEM(g_ary); g_next++)\n        EC_GROUP_free(*g_next);\n    for (p_next = &p_ary[0]; p_next < p_ary + OSSL_NELEM(g_ary); p_next++)\n        ECPARAMETERS_free(*p_next);\n    ECPARAMETERS_free(params);\n    EC_POINT_free(other_gen);\n    EC_GROUP_free(tmpg);\n    EC_GROUP_free(group);\n    BN_CTX_end(bn_ctx);\n    BN_CTX_free(bn_ctx);\n    return ret;\n}', 'void BN_CTX_start(BN_CTX *ctx)\n{\n    CTXDBG("ENTER BN_CTX_start()", ctx);\n    if (ctx->err_stack || ctx->too_many)\n        ctx->err_stack++;\n    else if (!BN_STACK_push(&ctx->stack, ctx->used)) {\n        BNerr(BN_F_BN_CTX_START, BN_R_TOO_MANY_TEMPORARY_VARIABLES);\n        ctx->err_stack++;\n    }\n    CTXDBG("LEAVE BN_CTX_start()", ctx);\n}', 'void BN_CTX_end(BN_CTX *ctx)\n{\n    if (ctx == NULL)\n        return;\n    CTXDBG("ENTER BN_CTX_end()", ctx);\n    if (ctx->err_stack)\n        ctx->err_stack--;\n    else {\n        unsigned int fp = BN_STACK_pop(&ctx->stack);\n        if (fp < ctx->used)\n            BN_POOL_release(&ctx->pool, ctx->used - fp);\n        ctx->used = fp;\n        ctx->too_many = 0;\n    }\n    CTXDBG("LEAVE BN_CTX_end()", ctx);\n}', 'static unsigned int BN_STACK_pop(BN_STACK *st)\n{\n    return st->indexes[--(st->depth)];\n}']