apps/apps.c:1437: error: MEMORY_LEAK
  memory dynamically allocated by call to `ASN1_INTEGER_new()` at line 1403, column 10 is not reachable after line 1437, column 5.
Showing all 81 steps of the trace


apps/apps.c:1396:1: start of procedure load_serial()
1394.   #undef BSIZE
1395.   #define BSIZE 256
1396. > BIGNUM *load_serial(char *serialfile, int create, ASN1_INTEGER **retai)
1397.   {
1398.       BIO *in = NULL;

apps/apps.c:1398:5: 
1396.   BIGNUM *load_serial(char *serialfile, int create, ASN1_INTEGER **retai)
1397.   {
1398. >     BIO *in = NULL;
1399.       BIGNUM *ret = NULL;
1400.       char buf[1024];

apps/apps.c:1399:5: 
1397.   {
1398.       BIO *in = NULL;
1399. >     BIGNUM *ret = NULL;
1400.       char buf[1024];
1401.       ASN1_INTEGER *ai = NULL;

apps/apps.c:1401:5: 
1399.       BIGNUM *ret = NULL;
1400.       char buf[1024];
1401. >     ASN1_INTEGER *ai = NULL;
1402.   
1403.       ai = ASN1_INTEGER_new();

apps/apps.c:1403:5: 
1401.       ASN1_INTEGER *ai = NULL;
1402.   
1403. >     ai = ASN1_INTEGER_new();
1404.       if (ai == NULL)
1405.           goto err;

crypto/asn1/tasn_typ.c:77:1: start of procedure ASN1_INTEGER_new()
  75.   
  76.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_OCTET_STRING)
  77. > IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_INTEGER)
  78.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_ENUMERATED)
  79.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_BIT_STRING)

crypto/asn1/asn1_lib.c:348:1: start of procedure ASN1_STRING_type_new()
    346.   }
    347.   
    348. > ASN1_STRING *ASN1_STRING_type_new(int type)
    349.   {
    350.       ASN1_STRING *ret;

crypto/asn1/asn1_lib.c:352:5: 
    350.       ASN1_STRING *ret;
    351.   
    352. >     ret = OPENSSL_zalloc(sizeof(*ret));
    353.       if (ret == NULL) {
    354.           ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW, ERR_R_MALLOC_FAILURE);

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/asn1/asn1_lib.c:353:9: Taking false branch
    351.   
    352.       ret = OPENSSL_zalloc(sizeof(*ret));
    353.       if (ret == NULL) {
                   ^
    354.           ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW, ERR_R_MALLOC_FAILURE);
    355.           return (NULL);

crypto/asn1/asn1_lib.c:357:5: 
    355.           return (NULL);
    356.       }
    357. >     ret->type = type;
    358.       return (ret);
    359.   }

crypto/asn1/asn1_lib.c:358:5: 
    356.       }
    357.       ret->type = type;
    358. >     return (ret);
    359.   }
    360.   

crypto/asn1/asn1_lib.c:359:1: return from a call to ASN1_STRING_type_new
    357.       ret->type = type;
    358.       return (ret);
    359. > }
    360.   
    361.   void ASN1_STRING_free(ASN1_STRING *a)

crypto/asn1/tasn_typ.c:77:1: return from a call to ASN1_INTEGER_new
  75.   
  76.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_OCTET_STRING)
  77. > IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_INTEGER)
  78.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_ENUMERATED)
  79.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_BIT_STRING)

apps/apps.c:1404:9: Taking false branch
1402.   
1403.       ai = ASN1_INTEGER_new();
1404.       if (ai == NULL)
                ^
1405.           goto err;
1406.   

apps/apps.c:1407:5: Skipping BIO_new_file(): empty list of specs
1405.           goto err;
1406.   
1407.       in = BIO_new_file(serialfile, "r");
            ^
1408.       if (in == NULL) {
1409.           if (!create) {

apps/apps.c:1408:9: Taking false branch
1406.   
1407.       in = BIO_new_file(serialfile, "r");
1408.       if (in == NULL) {
                ^
1409.           if (!create) {
1410.               perror(serialfile);

apps/apps.c:1418:14: Taking false branch
1416.               BIO_printf(bio_err, "Out of memory\n");
1417.       } else {
1418.           if (!a2i_ASN1_INTEGER(in, ai, buf, 1024)) {
                     ^
1419.               BIO_printf(bio_err, "unable to load number from %s\n",
1420.                          serialfile);

apps/apps.c:1423:9: 
1421.               goto err;
1422.           }
1423. >         ret = ASN1_INTEGER_to_BN(ai, NULL);
1424.           if (ret == NULL) {
1425.               BIO_printf(bio_err,

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)

apps/apps.c:1424:13: Taking true branch
1422.           }
1423.           ret = ASN1_INTEGER_to_BN(ai, NULL);
1424.           if (ret == NULL) {
                    ^
1425.               BIO_printf(bio_err,
1426.                          "error converting number from bin to BIGNUM\n");

apps/apps.c:1425:13: Skipping BIO_printf(): empty list of specs
1423.           ret = ASN1_INTEGER_to_BN(ai, NULL);
1424.           if (ret == NULL) {
1425.               BIO_printf(bio_err,
                    ^
1426.                          "error converting number from bin to BIGNUM\n");
1427.               goto err;

apps/apps.c:1435:2: 
1433.           ai = NULL;
1434.       }
1435. >  err:
1436.       BIO_free(in);
1437.       ASN1_INTEGER_free(ai);

apps/apps.c:1436:5: 
1434.       }
1435.    err:
1436. >     BIO_free(in);
1437.       ASN1_INTEGER_free(ai);
1438.       return (ret);

crypto/bio/bio_lib.c:105:1: start of procedure BIO_free()
  103.   }
  104.   
  105. > int BIO_free(BIO *a)
  106.   {
  107.       int i;

crypto/bio/bio_lib.c:109:9: Taking false branch
  107.       int i;
  108.   
  109.       if (a == NULL)
                 ^
  110.           return (0);
  111.   

crypto/bio/bio_lib.c:112:5: 
  110.           return (0);
  111.   
  112. >     i = CRYPTO_add(&a->references, -1, CRYPTO_LOCK_BIO);
  113.       REF_PRINT_COUNT("BIO", a);
  114.       if (i > 0)

crypto/lock.c:456:1: start of procedure CRYPTO_add_lock()
    454.   }
    455.   
    456. > int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,
    457.                       int line)
    458.   {

crypto/lock.c:459:5: 
    457.                       int line)
    458.   {
    459. >     int ret = 0;
    460.   
    461.       if (add_lock_callback != NULL) {

crypto/lock.c:461:9: Taking false branch
    459.       int ret = 0;
    460.   
    461.       if (add_lock_callback != NULL) {
                   ^
    462.   #ifdef LOCK_DEBUG
    463.           int before = *pointer;

crypto/lock.c:477:9: 
    475.   #endif
    476.       } else {
    477. >         CRYPTO_lock(CRYPTO_LOCK | CRYPTO_WRITE, type, file, line);
    478.   
    479.           ret = *pointer + amount;

crypto/lock.c:414:1: start of procedure CRYPTO_lock()
      412.   }
      413.   
      414. > void CRYPTO_lock(int mode, int type, const char *file, int line)
      415.   {
      416.   #ifdef LOCK_DEBUG

crypto/lock.c:441:9: Taking false branch
      439.       }
      440.   #endif
      441.       if (type < 0) {
                     ^
      442.           if (dynlock_lock_callback != NULL) {
      443.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:452:16: Taking false branch
      450.               CRYPTO_destroy_dynlockid(type);
      451.           }
      452.       } else if (locking_callback != NULL)
                            ^
      453.           locking_callback(mode, type, file, line);
      454.   }

crypto/lock.c:441:5: 
      439.       }
      440.   #endif
      441. >     if (type < 0) {
      442.           if (dynlock_lock_callback != NULL) {
      443.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:454:1: return from a call to CRYPTO_lock
      452.       } else if (locking_callback != NULL)
      453.           locking_callback(mode, type, file, line);
      454. > }
      455.   
      456.   int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,

crypto/lock.c:479:9: 
    477.           CRYPTO_lock(CRYPTO_LOCK | CRYPTO_WRITE, type, file, line);
    478.   
    479. >         ret = *pointer + amount;
    480.   #ifdef LOCK_DEBUG
    481.           {

crypto/lock.c:490:9: 
    488.           }
    489.   #endif
    490. >         *pointer = ret;
    491.           CRYPTO_lock(CRYPTO_UNLOCK | CRYPTO_WRITE, type, file, line);
    492.       }

crypto/lock.c:491:9: 
    489.   #endif
    490.           *pointer = ret;
    491. >         CRYPTO_lock(CRYPTO_UNLOCK | CRYPTO_WRITE, type, file, line);
    492.       }
    493.       return (ret);

crypto/lock.c:414:1: start of procedure CRYPTO_lock()
      412.   }
      413.   
      414. > void CRYPTO_lock(int mode, int type, const char *file, int line)
      415.   {
      416.   #ifdef LOCK_DEBUG

crypto/lock.c:441:9: Taking false branch
      439.       }
      440.   #endif
      441.       if (type < 0) {
                     ^
      442.           if (dynlock_lock_callback != NULL) {
      443.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:452:16: Taking false branch
      450.               CRYPTO_destroy_dynlockid(type);
      451.           }
      452.       } else if (locking_callback != NULL)
                            ^
      453.           locking_callback(mode, type, file, line);
      454.   }

crypto/lock.c:441:5: 
      439.       }
      440.   #endif
      441. >     if (type < 0) {
      442.           if (dynlock_lock_callback != NULL) {
      443.               struct CRYPTO_dynlock_value *pointer

crypto/lock.c:454:1: return from a call to CRYPTO_lock
      452.       } else if (locking_callback != NULL)
      453.           locking_callback(mode, type, file, line);
      454. > }
      455.   
      456.   int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,

crypto/lock.c:493:5: 
    491.           CRYPTO_lock(CRYPTO_UNLOCK | CRYPTO_WRITE, type, file, line);
    492.       }
    493. >     return (ret);
    494.   }
    495.   

crypto/lock.c:494:1: return from a call to CRYPTO_add_lock
    492.       }
    493.       return (ret);
    494. > }
    495.   
    496.   const char *CRYPTO_get_lock_name(int type)

crypto/bio/bio_lib.c:114:9: Taking false branch
  112.       i = CRYPTO_add(&a->references, -1, CRYPTO_LOCK_BIO);
  113.       REF_PRINT_COUNT("BIO", a);
  114.       if (i > 0)
                 ^
  115.           return (1);
  116.       REF_ASSERT_ISNT(i < 0);

crypto/bio/bio_lib.c:117:10: Taking true branch
  115.           return (1);
  116.       REF_ASSERT_ISNT(i < 0);
  117.       if ((a->callback != NULL) &&
                  ^
  118.           ((i = (int)a->callback(a, BIO_CB_FREE, NULL, 0, 0L, 1L)) <= 0))
  119.           return (i);

crypto/bio/bio_lib.c:118:10: Taking true branch
  116.       REF_ASSERT_ISNT(i < 0);
  117.       if ((a->callback != NULL) &&
  118.           ((i = (int)a->callback(a, BIO_CB_FREE, NULL, 0, 0L, 1L)) <= 0))
                  ^
  119.           return (i);
  120.   

crypto/bio/bio_lib.c:119:9: 
  117.       if ((a->callback != NULL) &&
  118.           ((i = (int)a->callback(a, BIO_CB_FREE, NULL, 0, 0L, 1L)) <= 0))
  119. >         return (i);
  120.   
  121.       CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, a, &a->ex_data);

crypto/bio/bio_lib.c:127:1: return from a call to BIO_free
  125.       OPENSSL_free(a);
  126.       return (1);
  127. > }
  128.   
  129.   void BIO_vfree(BIO *a)

apps/apps.c:1437:5: 
1435.    err:
1436.       BIO_free(in);
1437. >     ASN1_INTEGER_free(ai);
1438.       return (ret);
1439.   }

crypto/asn1/tasn_typ.c:77:1: start of procedure ASN1_INTEGER_free()
  75.   
  76.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_OCTET_STRING)
  77. > IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_INTEGER)
  78.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_ENUMERATED)
  79.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_BIT_STRING)

crypto/asn1/asn1_lib.c:361:1: start of procedure ASN1_STRING_free()
    359.   }
    360.   
    361. > void ASN1_STRING_free(ASN1_STRING *a)
    362.   {
    363.       if (a == NULL)

crypto/asn1/asn1_lib.c:363:9: Taking false branch
    361.   void ASN1_STRING_free(ASN1_STRING *a)
    362.   {
    363.       if (a == NULL)
                   ^
    364.           return;
    365.       if (!(a->flags & ASN1_STRING_FLAG_NDEF))

crypto/asn1/asn1_lib.c:365:11: Taking false branch
    363.       if (a == NULL)
    364.           return;
    365.       if (!(a->flags & ASN1_STRING_FLAG_NDEF))
                     ^
    366.           OPENSSL_free(a->data);
    367.       if (!(a->flags & ASN1_STRING_FLAG_EMBED))

crypto/asn1/asn1_lib.c:367:11: Taking false branch
    365.       if (!(a->flags & ASN1_STRING_FLAG_NDEF))
    366.           OPENSSL_free(a->data);
    367.       if (!(a->flags & ASN1_STRING_FLAG_EMBED))
                     ^
    368.           OPENSSL_free(a);
    369.   }

crypto/asn1/asn1_lib.c:367:5: 
    365.       if (!(a->flags & ASN1_STRING_FLAG_NDEF))
    366.           OPENSSL_free(a->data);
    367. >     if (!(a->flags & ASN1_STRING_FLAG_EMBED))
    368.           OPENSSL_free(a);
    369.   }

crypto/asn1/asn1_lib.c:369:1: return from a call to ASN1_STRING_free
    367.       if (!(a->flags & ASN1_STRING_FLAG_EMBED))
    368.           OPENSSL_free(a);
    369. > }
    370.   
    371.   void ASN1_STRING_clear_free(ASN1_STRING *a)

crypto/asn1/tasn_typ.c:77:1: return from a call to ASN1_INTEGER_free
  75.   
  76.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_OCTET_STRING)
  77. > IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_INTEGER)
  78.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_ENUMERATED)
  79.   IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_BIT_STRING)

BIGNUM *load_serial(char *serialfile, int create, ASN1_INTEGER **retai)
{
    BIO *in = NULL;
    BIGNUM *ret = NULL;
    char buf[1024];
    ASN1_INTEGER *ai = NULL;
    ai = ASN1_INTEGER_new();
    if (ai == NULL)
        goto err;
    in = BIO_new_file(serialfile, "r");
    if (in == NULL) {
        if (!create) {
            perror(serialfile);
            goto err;
        }
        ERR_clear_error();
        ret = BN_new();
        if (ret == NULL || !rand_serial(ret, ai))
            BIO_printf(bio_err, "Out of memory\n");
    } else {
        if (!a2i_ASN1_INTEGER(in, ai, buf, 1024)) {
            BIO_printf(bio_err, "unable to load number from %s\n",
                       serialfile);
            goto err;
        }
        ret = ASN1_INTEGER_to_BN(ai, NULL);
        if (ret == NULL) {
            BIO_printf(bio_err,
                       "error converting number from bin to BIGNUM\n");
            goto err;
        }
    }
    if (ret && retai) {
        *retai = ai;
        ai = NULL;
    }
 err:
    BIO_free(in);
    ASN1_INTEGER_free(ai);
    return (ret);
}
['BIGNUM *load_serial(char *serialfile, int create, ASN1_INTEGER **retai)\n{\n    BIO *in = NULL;\n    BIGNUM *ret = NULL;\n    char buf[1024];\n    ASN1_INTEGER *ai = NULL;\n    ai = ASN1_INTEGER_new();\n    if (ai == NULL)\n        goto err;\n    in = BIO_new_file(serialfile, "r");\n    if (in == NULL) {\n        if (!create) {\n            perror(serialfile);\n            goto err;\n        }\n        ERR_clear_error();\n        ret = BN_new();\n        if (ret == NULL || !rand_serial(ret, ai))\n            BIO_printf(bio_err, "Out of memory\\n");\n    } else {\n        if (!a2i_ASN1_INTEGER(in, ai, buf, 1024)) {\n            BIO_printf(bio_err, "unable to load number from %s\\n",\n                       serialfile);\n            goto err;\n        }\n        ret = ASN1_INTEGER_to_BN(ai, NULL);\n        if (ret == NULL) {\n            BIO_printf(bio_err,\n                       "error converting number from bin to BIGNUM\\n");\n            goto err;\n        }\n    }\n    if (ret && retai) {\n        *retai = ai;\n        ai = NULL;\n    }\n err:\n    BIO_free(in);\n    ASN1_INTEGER_free(ai);\n    return (ret);\n}', 'IMPLEMENT_ASN1_STRING_FUNCTIONS(ASN1_INTEGER)', 'ASN1_STRING *ASN1_STRING_type_new(int type)\n{\n    ASN1_STRING *ret;\n    ret = OPENSSL_zalloc(sizeof(*ret));\n    if (ret == NULL) {\n        ASN1err(ASN1_F_ASN1_STRING_TYPE_NEW, ERR_R_MALLOC_FAILURE);\n        return (NULL);\n    }\n    ret->type = type;\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_free(BIO *a)\n{\n    int i;\n    if (a == NULL)\n        return (0);\n    i = CRYPTO_add(&a->references, -1, CRYPTO_LOCK_BIO);\n    REF_PRINT_COUNT("BIO", a);\n    if (i > 0)\n        return (1);\n    REF_ASSERT_ISNT(i < 0);\n    if ((a->callback != NULL) &&\n        ((i = (int)a->callback(a, BIO_CB_FREE, NULL, 0, 0L, 1L)) <= 0))\n        return (i);\n    CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, a, &a->ex_data);\n    if ((a->method != NULL) && (a->method->destroy != NULL))\n        a->method->destroy(a);\n    OPENSSL_free(a);\n    return (1);\n}', 'int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file,\n                    int line)\n{\n    int ret = 0;\n    if (add_lock_callback != NULL) {\n#ifdef LOCK_DEBUG\n        int before = *pointer;\n#endif\n        ret = add_lock_callback(pointer, amount, type, file, line);\n#ifdef LOCK_DEBUG\n        {\n            CRYPTO_THREADID id;\n            CRYPTO_THREADID_current(&id);\n            fprintf(stderr, "ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\\n",\n                    CRYPTO_THREADID_hash(&id), before, amount, ret,\n                    CRYPTO_get_lock_name(type), file, line);\n        }\n#endif\n    } else {\n        CRYPTO_lock(CRYPTO_LOCK | CRYPTO_WRITE, type, file, line);\n        ret = *pointer + amount;\n#ifdef LOCK_DEBUG\n        {\n            CRYPTO_THREADID id;\n            CRYPTO_THREADID_current(&id);\n            fprintf(stderr, "ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\\n",\n                    CRYPTO_THREADID_hash(&id),\n                    *pointer, amount, ret,\n                    CRYPTO_get_lock_name(type), file, line);\n        }\n#endif\n        *pointer = ret;\n        CRYPTO_lock(CRYPTO_UNLOCK | CRYPTO_WRITE, type, file, line);\n    }\n    return (ret);\n}', 'void CRYPTO_lock(int mode, int type, const char *file, int line)\n{\n#ifdef LOCK_DEBUG\n    {\n        CRYPTO_THREADID id;\n        char *rw_text, *operation_text;\n        if (mode & CRYPTO_LOCK)\n            operation_text = "lock  ";\n        else if (mode & CRYPTO_UNLOCK)\n            operation_text = "unlock";\n        else\n            operation_text = "ERROR ";\n        if (mode & CRYPTO_READ)\n            rw_text = "r";\n        else if (mode & CRYPTO_WRITE)\n            rw_text = "w";\n        else\n            rw_text = "ERROR";\n        CRYPTO_THREADID_current(&id);\n        fprintf(stderr, "lock:%08lx:(%s)%s %-18s %s:%d\\n",\n                CRYPTO_THREADID_hash(&id), rw_text, operation_text,\n                CRYPTO_get_lock_name(type), file, line);\n    }\n#endif\n    if (type < 0) {\n        if (dynlock_lock_callback != NULL) {\n            struct CRYPTO_dynlock_value *pointer\n                = CRYPTO_get_dynlock_value(type);\n            OPENSSL_assert(pointer != NULL);\n            dynlock_lock_callback(mode, pointer, file, line);\n            CRYPTO_destroy_dynlockid(type);\n        }\n    } else if (locking_callback != NULL)\n        locking_callback(mode, type, file, line);\n}', 'void ASN1_STRING_free(ASN1_STRING *a)\n{\n    if (a == NULL)\n        return;\n    if (!(a->flags & ASN1_STRING_FLAG_NDEF))\n        OPENSSL_free(a->data);\n    if (!(a->flags & ASN1_STRING_FLAG_EMBED))\n        OPENSSL_free(a);\n}']