crypto/ts/ts_lib.c:83: error: MEMORY_LEAK
  memory dynamically allocated by call to `BN_new()` at line 74, column 14 is not reachable after line 83, column 5.
Showing all 72 steps of the trace


crypto/ts/ts_lib.c:68:1: start of procedure TS_ASN1_INTEGER_print_bio()
66.   #include "ts_lcl.h"
67.   
68. > int TS_ASN1_INTEGER_print_bio(BIO *bio, const ASN1_INTEGER *num)
69.   {
70.       BIGNUM *num_bn;

crypto/ts/ts_lib.c:71:5: 
69.   {
70.       BIGNUM *num_bn;
71. >     int result = 0;
72.       char *hex;
73.   

crypto/ts/ts_lib.c:74:5: 
72.       char *hex;
73.   
74. >     num_bn = BN_new();
75.       if (num_bn == NULL)
76.           return -1;

crypto/bn/bn_lib.c:276:1: start of procedure BN_new()
  274.   }
  275.   
  276. > BIGNUM *BN_new(void)
  277.   {
  278.       BIGNUM *ret;

crypto/bn/bn_lib.c:280:9: 
  278.       BIGNUM *ret;
  279.   
  280. >     if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {
  281.           BNerr(BN_F_BN_NEW, ERR_R_MALLOC_FAILURE);
  282.           return (NULL);

crypto/mem.c:156:1: start of procedure CRYPTO_zalloc()
    154.   }
    155.   
    156. > void *CRYPTO_zalloc(size_t num, const char *file, int line)
    157.   {
    158.       void *ret = CRYPTO_malloc(num, file, line);

crypto/mem.c:158:5: 
    156.   void *CRYPTO_zalloc(size_t num, const char *file, int line)
    157.   {
    158. >     void *ret = CRYPTO_malloc(num, file, line);
    159.   
    160.       if (ret != NULL)

crypto/mem.c:119:1: start of procedure CRYPTO_malloc()
      117.   }
      118.   
      119. > void *CRYPTO_malloc(size_t num, const char *file, int line)
      120.   {
      121.       void *ret = NULL;

crypto/mem.c:121:5: 
      119.   void *CRYPTO_malloc(size_t num, const char *file, int line)
      120.   {
      121. >     void *ret = NULL;
      122.   
      123.       if (num <= 0)

crypto/mem.c:123:9: Taking false branch
      121.       void *ret = NULL;
      122.   
      123.       if (num <= 0)
                     ^
      124.           return NULL;
      125.   

crypto/mem.c:126:5: 
      124.           return NULL;
      125.   
      126. >     allow_customize = 0;
      127.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
      128.       if (call_malloc_debug) {

crypto/mem.c:136:5: 
      134.       }
      135.   #else
      136. >     (void)file;
      137.       (void)line;
      138.       ret = malloc(num);

crypto/mem.c:137:5: 
      135.   #else
      136.       (void)file;
      137. >     (void)line;
      138.       ret = malloc(num);
      139.   #endif

crypto/mem.c:138:5: 
      136.       (void)file;
      137.       (void)line;
      138. >     ret = malloc(num);
      139.   #endif
      140.   

crypto/mem.c:153:5: 
      151.   #endif
      152.   
      153. >     return ret;
      154.   }
      155.   

crypto/mem.c:154:1: return from a call to CRYPTO_malloc
      152.   
      153.       return ret;
      154. > }
      155.   
      156.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/mem.c:160:9: Taking true branch
    158.       void *ret = CRYPTO_malloc(num, file, line);
    159.   
    160.       if (ret != NULL)
                   ^
    161.           memset(ret, 0, num);
    162.       return ret;

crypto/mem.c:161:9: 
    159.   
    160.       if (ret != NULL)
    161. >         memset(ret, 0, num);
    162.       return ret;
    163.   }

crypto/mem.c:162:5: 
    160.       if (ret != NULL)
    161.           memset(ret, 0, num);
    162. >     return ret;
    163.   }
    164.   

crypto/mem.c:163:1: return from a call to CRYPTO_zalloc
    161.           memset(ret, 0, num);
    162.       return ret;
    163. > }
    164.   
    165.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)

crypto/bn/bn_lib.c:280:9: Taking false branch
  278.       BIGNUM *ret;
  279.   
  280.       if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {
                 ^
  281.           BNerr(BN_F_BN_NEW, ERR_R_MALLOC_FAILURE);
  282.           return (NULL);

crypto/bn/bn_lib.c:284:5: 
  282.           return (NULL);
  283.       }
  284. >     ret->flags = BN_FLG_MALLOCED;
  285.       bn_check_top(ret);
  286.       return (ret);

crypto/bn/bn_lib.c:286:5: 
  284.       ret->flags = BN_FLG_MALLOCED;
  285.       bn_check_top(ret);
  286. >     return (ret);
  287.   }
  288.   

crypto/bn/bn_lib.c:287:1: return from a call to BN_new
  285.       bn_check_top(ret);
  286.       return (ret);
  287. > }
  288.   
  289.    BIGNUM *BN_secure_new(void)

crypto/ts/ts_lib.c:75:9: Taking false branch
73.   
74.       num_bn = BN_new();
75.       if (num_bn == NULL)
              ^
76.           return -1;
77.       ASN1_INTEGER_to_BN(num, num_bn);

crypto/ts/ts_lib.c:77:5: 
75.       if (num_bn == NULL)
76.           return -1;
77. >     ASN1_INTEGER_to_BN(num, num_bn);
78.       if ((hex = BN_bn2hex(num_bn))) {
79.           result = BIO_write(bio, "0x", 2) > 0;

crypto/asn1/a_int.c:626:1: start of procedure ASN1_INTEGER_to_BN()
  624.   }
  625.   
  626. > BIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn)
  627.   {
  628.       return asn1_string_to_bn(ai, bn, V_ASN1_INTEGER);

crypto/asn1/a_int.c:628:5: 
  626.   BIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn)
  627.   {
  628. >     return asn1_string_to_bn(ai, bn, V_ASN1_INTEGER);
  629.   }
  630.   

crypto/asn1/a_int.c:562:1: start of procedure asn1_string_to_bn()
    560.   }
    561.   
    562. > static BIGNUM *asn1_string_to_bn(const ASN1_INTEGER *ai, BIGNUM *bn,
    563.                                    int itype)
    564.   {

crypto/asn1/a_int.c:567:9: Taking true branch
    565.       BIGNUM *ret;
    566.   
    567.       if ((ai->type & ~V_ASN1_NEG) != itype) {
                   ^
    568.           ASN1err(ASN1_F_ASN1_STRING_TO_BN, ASN1_R_WRONG_INTEGER_TYPE);
    569.           return NULL;

crypto/asn1/a_int.c:568:9: Skipping ERR_put_error(): empty list of specs
    566.   
    567.       if ((ai->type & ~V_ASN1_NEG) != itype) {
    568.           ASN1err(ASN1_F_ASN1_STRING_TO_BN, ASN1_R_WRONG_INTEGER_TYPE);
                   ^
    569.           return NULL;
    570.       }

crypto/asn1/a_int.c:569:9: 
    567.       if ((ai->type & ~V_ASN1_NEG) != itype) {
    568.           ASN1err(ASN1_F_ASN1_STRING_TO_BN, ASN1_R_WRONG_INTEGER_TYPE);
    569. >         return NULL;
    570.       }
    571.   

crypto/asn1/a_int.c:580:1: return from a call to asn1_string_to_bn
    578.           BN_set_negative(ret, 1);
    579.       return ret;
    580. > }
    581.   
    582.   int ASN1_INTEGER_get_int64(int64_t *pr, const ASN1_INTEGER *a)

crypto/asn1/a_int.c:629:1: return from a call to ASN1_INTEGER_to_BN
  627.   {
  628.       return asn1_string_to_bn(ai, bn, V_ASN1_INTEGER);
  629. > }
  630.   
  631.   int ASN1_ENUMERATED_get_int64(int64_t *pr, const ASN1_ENUMERATED *a)

crypto/ts/ts_lib.c:78:10: Taking true branch
76.           return -1;
77.       ASN1_INTEGER_to_BN(num, num_bn);
78.       if ((hex = BN_bn2hex(num_bn))) {
               ^
79.           result = BIO_write(bio, "0x", 2) > 0;
80.           result = result && BIO_write(bio, hex, strlen(hex)) > 0;

crypto/ts/ts_lib.c:79:18: 
77.       ASN1_INTEGER_to_BN(num, num_bn);
78.       if ((hex = BN_bn2hex(num_bn))) {
79. >         result = BIO_write(bio, "0x", 2) > 0;
80.           result = result && BIO_write(bio, hex, strlen(hex)) > 0;
81.           OPENSSL_free(hex);

crypto/bio/bio_lib.c:218:1: start of procedure BIO_write()
  216.   }
  217.   
  218. > int BIO_write(BIO *b, const void *in, int inl)
  219.   {
  220.       int i;

crypto/bio/bio_lib.c:223:9: Taking false branch
  221.       long (*cb) (BIO *, int, const char *, int, long, long);
  222.   
  223.       if (b == NULL)
                 ^
  224.           return (0);
  225.   

crypto/bio/bio_lib.c:226:5: 
  224.           return (0);
  225.   
  226. >     cb = b->callback;
  227.       if ((b->method == NULL) || (b->method->bwrite == NULL)) {
  228.           BIOerr(BIO_F_BIO_WRITE, BIO_R_UNSUPPORTED_METHOD);

crypto/bio/bio_lib.c:227:10: Taking false branch
  225.   
  226.       cb = b->callback;
  227.       if ((b->method == NULL) || (b->method->bwrite == NULL)) {
                  ^
  228.           BIOerr(BIO_F_BIO_WRITE, BIO_R_UNSUPPORTED_METHOD);
  229.           return (-2);

crypto/bio/bio_lib.c:227:33: Taking false branch
  225.   
  226.       cb = b->callback;
  227.       if ((b->method == NULL) || (b->method->bwrite == NULL)) {
                                         ^
  228.           BIOerr(BIO_F_BIO_WRITE, BIO_R_UNSUPPORTED_METHOD);
  229.           return (-2);

crypto/bio/bio_lib.c:232:10: Taking true branch
  230.       }
  231.   
  232.       if ((cb != NULL) &&
                  ^
  233.           ((i = (int)cb(b, BIO_CB_WRITE, in, inl, 0L, 1L)) <= 0))
  234.           return (i);

crypto/bio/bio_lib.c:233:10: Taking false branch
  231.   
  232.       if ((cb != NULL) &&
  233.           ((i = (int)cb(b, BIO_CB_WRITE, in, inl, 0L, 1L)) <= 0))
                  ^
  234.           return (i);
  235.   

crypto/bio/bio_lib.c:236:10: Taking false branch
  234.           return (i);
  235.   
  236.       if (!b->init) {
                  ^
  237.           BIOerr(BIO_F_BIO_WRITE, BIO_R_UNINITIALIZED);
  238.           return (-2);

crypto/bio/bio_lib.c:241:5: Skipping __function_pointer__(): unresolved function pointer
  239.       }
  240.   
  241.       i = b->method->bwrite(b, in, inl);
             ^
  242.   
  243.       if (i > 0)

crypto/bio/bio_lib.c:243:9: Taking true branch
  241.       i = b->method->bwrite(b, in, inl);
  242.   
  243.       if (i > 0)
                 ^
  244.           b->num_write += (uint64_t)i;
  245.   

crypto/bio/bio_lib.c:244:9: 
  242.   
  243.       if (i > 0)
  244. >         b->num_write += (uint64_t)i;
  245.   
  246.       if (cb != NULL)

crypto/bio/bio_lib.c:246:9: Taking true branch
  244.           b->num_write += (uint64_t)i;
  245.   
  246.       if (cb != NULL)
                 ^
  247.           i = (int)cb(b, BIO_CB_WRITE | BIO_CB_RETURN, in, inl, 0L, (long)i);
  248.       return (i);

crypto/bio/bio_lib.c:247:9: Skipping __function_pointer__(): unresolved function pointer
  245.   
  246.       if (cb != NULL)
  247.           i = (int)cb(b, BIO_CB_WRITE | BIO_CB_RETURN, in, inl, 0L, (long)i);
                 ^
  248.       return (i);
  249.   }

crypto/bio/bio_lib.c:248:5: 
  246.       if (cb != NULL)
  247.           i = (int)cb(b, BIO_CB_WRITE | BIO_CB_RETURN, in, inl, 0L, (long)i);
  248. >     return (i);
  249.   }
  250.   

crypto/bio/bio_lib.c:249:1: return from a call to BIO_write
  247.           i = (int)cb(b, BIO_CB_WRITE | BIO_CB_RETURN, in, inl, 0L, (long)i);
  248.       return (i);
  249. > }
  250.   
  251.   int BIO_puts(BIO *b, const char *in)

crypto/ts/ts_lib.c:79:18: Condition is false
77.       ASN1_INTEGER_to_BN(num, num_bn);
78.       if ((hex = BN_bn2hex(num_bn))) {
79.           result = BIO_write(bio, "0x", 2) > 0;
                       ^
80.           result = result && BIO_write(bio, hex, strlen(hex)) > 0;
81.           OPENSSL_free(hex);

crypto/ts/ts_lib.c:79:9: 
77.       ASN1_INTEGER_to_BN(num, num_bn);
78.       if ((hex = BN_bn2hex(num_bn))) {
79. >         result = BIO_write(bio, "0x", 2) > 0;
80.           result = result && BIO_write(bio, hex, strlen(hex)) > 0;
81.           OPENSSL_free(hex);

crypto/ts/ts_lib.c:80:18: Condition is false
78.       if ((hex = BN_bn2hex(num_bn))) {
79.           result = BIO_write(bio, "0x", 2) > 0;
80.           result = result && BIO_write(bio, hex, strlen(hex)) > 0;
                       ^
81.           OPENSSL_free(hex);
82.       }

crypto/ts/ts_lib.c:80:9: 
78.       if ((hex = BN_bn2hex(num_bn))) {
79.           result = BIO_write(bio, "0x", 2) > 0;
80. >         result = result && BIO_write(bio, hex, strlen(hex)) > 0;
81.           OPENSSL_free(hex);
82.       }

crypto/ts/ts_lib.c:81:9: 
79.           result = BIO_write(bio, "0x", 2) > 0;
80.           result = result && BIO_write(bio, hex, strlen(hex)) > 0;
81. >         OPENSSL_free(hex);
82.       }
83.       BN_free(num_bn);

crypto/mem.c:233:1: start of procedure CRYPTO_free()
  231.   }
  232.   
  233. > void CRYPTO_free(void *str)
  234.   {
  235.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG

crypto/mem.c:244:5: 
  242.       }
  243.   #else
  244. >     free(str);
  245.   #endif
  246.   }

crypto/mem.c:246:1: return from a call to CRYPTO_free
  244.       free(str);
  245.   #endif
  246. > }
  247.   
  248.   void CRYPTO_clear_free(void *str, size_t num)

crypto/ts/ts_lib.c:83:5: 
81.           OPENSSL_free(hex);
82.       }
83. >     BN_free(num_bn);
84.   
85.       return result;

crypto/bn/bn_lib.c:251:1: start of procedure BN_free()
  249.   }
  250.   
  251. > void BN_free(BIGNUM *a)
  252.   {
  253.       if (a == NULL)

crypto/bn/bn_lib.c:253:9: Taking false branch
  251.   void BN_free(BIGNUM *a)
  252.   {
  253.       if (a == NULL)
                 ^
  254.           return;
  255.       bn_check_top(a);

crypto/bn/bn_lib.c:256:10: 
  254.           return;
  255.       bn_check_top(a);
  256. >     if (!BN_get_flags(a, BN_FLG_STATIC_DATA))
  257.           bn_free_d(a);
  258.       if (a->flags & BN_FLG_MALLOCED)

crypto/bn/bn_lib.c:1041:1: start of procedure BN_get_flags()
    1039.   }
    1040.   
    1041. > int BN_get_flags(const BIGNUM *b, int n)
    1042.   {
    1043.       return b->flags & n;

crypto/bn/bn_lib.c:1043:5: 
    1041.   int BN_get_flags(const BIGNUM *b, int n)
    1042.   {
    1043. >     return b->flags & n;
    1044.   }
    1045.   

crypto/bn/bn_lib.c:1044:1: return from a call to BN_get_flags
    1042.   {
    1043.       return b->flags & n;
    1044. > }
    1045.   
    1046.   /* Populate a BN_GENCB structure with an "old"-style callback */

crypto/bn/bn_lib.c:256:10: Taking false branch
  254.           return;
  255.       bn_check_top(a);
  256.       if (!BN_get_flags(a, BN_FLG_STATIC_DATA))
                  ^
  257.           bn_free_d(a);
  258.       if (a->flags & BN_FLG_MALLOCED)

crypto/bn/bn_lib.c:258:9: Taking false branch
  256.       if (!BN_get_flags(a, BN_FLG_STATIC_DATA))
  257.           bn_free_d(a);
  258.       if (a->flags & BN_FLG_MALLOCED)
                 ^
  259.           OPENSSL_free(a);
  260.       else {

crypto/bn/bn_lib.c:262:9: 
  260.       else {
  261.   #if OPENSSL_API_COMPAT < 0x00908000L
  262. >         a->flags |= BN_FLG_FREE;
  263.   #endif
  264.           a->d = NULL;

crypto/bn/bn_lib.c:264:9: 
  262.           a->flags |= BN_FLG_FREE;
  263.   #endif
  264. >         a->d = NULL;
  265.       }
  266.   }

crypto/bn/bn_lib.c:258:5: 
  256.       if (!BN_get_flags(a, BN_FLG_STATIC_DATA))
  257.           bn_free_d(a);
  258. >     if (a->flags & BN_FLG_MALLOCED)
  259.           OPENSSL_free(a);
  260.       else {

crypto/bn/bn_lib.c:266:1: return from a call to BN_free
  264.           a->d = NULL;
  265.       }
  266. > }
  267.   
  268.   void bn_init(BIGNUM *a)

int TS_ASN1_INTEGER_print_bio(BIO *bio, const ASN1_INTEGER *num)
{
    BIGNUM *num_bn;
    int result = 0;
    char *hex;
    num_bn = BN_new();
    if (num_bn == NULL)
        return -1;
    ASN1_INTEGER_to_BN(num, num_bn);
    if ((hex = BN_bn2hex(num_bn))) {
        result = BIO_write(bio, "0x", 2) > 0;
        result = result && BIO_write(bio, hex, strlen(hex)) > 0;
        OPENSSL_free(hex);
    }
    BN_free(num_bn);
    return result;
}
['int TS_ASN1_INTEGER_print_bio(BIO *bio, const ASN1_INTEGER *num)\n{\n    BIGNUM *num_bn;\n    int result = 0;\n    char *hex;\n    num_bn = BN_new();\n    if (num_bn == NULL)\n        return -1;\n    ASN1_INTEGER_to_BN(num, num_bn);\n    if ((hex = BN_bn2hex(num_bn))) {\n        result = BIO_write(bio, "0x", 2) > 0;\n        result = result && BIO_write(bio, hex, strlen(hex)) > 0;\n        OPENSSL_free(hex);\n    }\n    BN_free(num_bn);\n    return result;\n}', 'BIGNUM *BN_new(void)\n{\n    BIGNUM *ret;\n    if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL) {\n        BNerr(BN_F_BN_NEW, ERR_R_MALLOC_FAILURE);\n        return (NULL);\n    }\n    ret->flags = BN_FLG_MALLOCED;\n    bn_check_top(ret);\n    return (ret);\n}', 'void *CRYPTO_zalloc(size_t num, const char *file, int line)\n{\n    void *ret = CRYPTO_malloc(num, file, line);\n    if (ret != NULL)\n        memset(ret, 0, num);\n    return ret;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    if (num <= 0)\n        return NULL;\n    allow_customize = 0;\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);\n        ret = malloc(num);\n        CRYPTO_mem_debug_malloc(ret, num, 1, file, line);\n    } else {\n        ret = malloc(num);\n    }\n#else\n    (void)file;\n    (void)line;\n    ret = malloc(num);\n#endif\n#ifndef OPENSSL_CPUID_OBJ\n    if (ret && (num > 2048)) {\n        extern unsigned char cleanse_ctr;\n        ((unsigned char *)ret)[0] = cleanse_ctr;\n    }\n#endif\n    return ret;\n}', 'BIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn)\n{\n    return asn1_string_to_bn(ai, bn, V_ASN1_INTEGER);\n}', 'static BIGNUM *asn1_string_to_bn(const ASN1_INTEGER *ai, BIGNUM *bn,\n                                 int itype)\n{\n    BIGNUM *ret;\n    if ((ai->type & ~V_ASN1_NEG) != itype) {\n        ASN1err(ASN1_F_ASN1_STRING_TO_BN, ASN1_R_WRONG_INTEGER_TYPE);\n        return NULL;\n    }\n    ret = BN_bin2bn(ai->data, ai->length, bn);\n    if (ret == 0) {\n        ASN1err(ASN1_F_ASN1_STRING_TO_BN, ASN1_R_BN_LIB);\n        return NULL;\n    }\n    if (ai->type & V_ASN1_NEG)\n        BN_set_negative(ret, 1);\n    return ret;\n}', 'int BIO_write(BIO *b, const void *in, int inl)\n{\n    int i;\n    long (*cb) (BIO *, int, const char *, int, long, long);\n    if (b == NULL)\n        return (0);\n    cb = b->callback;\n    if ((b->method == NULL) || (b->method->bwrite == NULL)) {\n        BIOerr(BIO_F_BIO_WRITE, BIO_R_UNSUPPORTED_METHOD);\n        return (-2);\n    }\n    if ((cb != NULL) &&\n        ((i = (int)cb(b, BIO_CB_WRITE, in, inl, 0L, 1L)) <= 0))\n        return (i);\n    if (!b->init) {\n        BIOerr(BIO_F_BIO_WRITE, BIO_R_UNINITIALIZED);\n        return (-2);\n    }\n    i = b->method->bwrite(b, in, inl);\n    if (i > 0)\n        b->num_write += (uint64_t)i;\n    if (cb != NULL)\n        i = (int)cb(b, BIO_CB_WRITE | BIO_CB_RETURN, in, inl, 0L, (long)i);\n    return (i);\n}', 'void CRYPTO_free(void *str)\n{\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_free(str, 0);\n        free(str);\n        CRYPTO_mem_debug_free(str, 1);\n    } else {\n        free(str);\n    }\n#else\n    free(str);\n#endif\n}', 'void BN_free(BIGNUM *a)\n{\n    if (a == NULL)\n        return;\n    bn_check_top(a);\n    if (!BN_get_flags(a, BN_FLG_STATIC_DATA))\n        bn_free_d(a);\n    if (a->flags & BN_FLG_MALLOCED)\n        OPENSSL_free(a);\n    else {\n#if OPENSSL_API_COMPAT < 0x00908000L\n        a->flags |= BN_FLG_FREE;\n#endif\n        a->d = NULL;\n    }\n}', 'int BN_get_flags(const BIGNUM *b, int n)\n{\n    return b->flags & n;\n}']