crypto/cms/cms_smime.c:117: error: MEMORY_LEAK
  memory dynamically allocated by call to `cms_get_text_bio()` at line 82, column 14 is not reachable after line 117, column 9.
Showing all 76 steps of the trace


crypto/cms/cms_smime.c:76:1: start of procedure cms_copy_content()
74.   }
75.   
76. > static int cms_copy_content(BIO *out, BIO *in, unsigned int flags)
77.   {
78.       unsigned char buf[4096];

crypto/cms/cms_smime.c:79:5: 
77.   {
78.       unsigned char buf[4096];
79. >     int r = 0, i;
80.       BIO *tmpout;
81.   

crypto/cms/cms_smime.c:82:5: 
80.       BIO *tmpout;
81.   
82. >     tmpout = cms_get_text_bio(out, flags);
83.   
84.       if (tmpout == NULL) {

crypto/cms/cms_smime.c:63:1: start of procedure cms_get_text_bio()
  61.   #include "internal/asn1_int.h"
  62.   
  63. > static BIO *cms_get_text_bio(BIO *out, unsigned int flags)
  64.   {
  65.       BIO *rbio;

crypto/cms/cms_smime.c:66:9: Taking true branch
  64.   {
  65.       BIO *rbio;
  66.       if (out == NULL)
                ^
  67.           rbio = BIO_new(BIO_s_null());
  68.       else if (flags & CMS_TEXT) {

crypto/cms/cms_smime.c:67:9: 
  65.       BIO *rbio;
  66.       if (out == NULL)
  67. >         rbio = BIO_new(BIO_s_null());
  68.       else if (flags & CMS_TEXT) {
  69.           rbio = BIO_new(BIO_s_mem());

crypto/bio/bss_null.c:83:1: start of procedure BIO_s_null()
    81.   };
    82.   
    83. > BIO_METHOD *BIO_s_null(void)
    84.   {
    85.       return (&null_method);

crypto/bio/bss_null.c:85:5: 
    83.   BIO_METHOD *BIO_s_null(void)
    84.   {
    85. >     return (&null_method);
    86.   }
    87.   

crypto/bio/bss_null.c:86:1: return from a call to BIO_s_null
    84.   {
    85.       return (&null_method);
    86. > }
    87.   
    88.   static int null_new(BIO *bi)

crypto/bio/bio_lib.c:65:1: start of procedure BIO_new()
    63.   #include <openssl/stack.h>
    64.   
    65. > BIO *BIO_new(BIO_METHOD *method)
    66.   {
    67.       BIO *ret = OPENSSL_malloc(sizeof(*ret));

crypto/bio/bio_lib.c:67:5: 
    65.   BIO *BIO_new(BIO_METHOD *method)
    66.   {
    67. >     BIO *ret = OPENSSL_malloc(sizeof(*ret));
    68.   
    69.       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/bio/bio_lib.c:69:9: Taking false branch
    67.       BIO *ret = OPENSSL_malloc(sizeof(*ret));
    68.   
    69.       if (ret == NULL) {
                  ^
    70.           BIOerr(BIO_F_BIO_NEW, ERR_R_MALLOC_FAILURE);
    71.           return (NULL);

crypto/bio/bio_lib.c:73:10: Taking false branch
    71.           return (NULL);
    72.       }
    73.       if (!BIO_set(ret, method)) {
                   ^
    74.           OPENSSL_free(ret);
    75.           ret = NULL;

crypto/bio/bio_lib.c:77:5: 
    75.           ret = NULL;
    76.       }
    77. >     return (ret);
    78.   }
    79.   

crypto/bio/bio_lib.c:78:1: return from a call to BIO_new
    76.       }
    77.       return (ret);
    78. > }
    79.   
    80.   int BIO_set(BIO *bio, BIO_METHOD *method)

crypto/cms/cms_smime.c:73:5: 
  71.       } else
  72.           rbio = out;
  73. >     return rbio;
  74.   }
  75.   

crypto/cms/cms_smime.c:74:1: return from a call to cms_get_text_bio
  72.           rbio = out;
  73.       return rbio;
  74. > }
  75.   
  76.   static int cms_copy_content(BIO *out, BIO *in, unsigned int flags)

crypto/cms/cms_smime.c:84:9: Taking false branch
82.       tmpout = cms_get_text_bio(out, flags);
83.   
84.       if (tmpout == NULL) {
              ^
85.           CMSerr(CMS_F_CMS_COPY_CONTENT, ERR_R_MALLOC_FAILURE);
86.           goto err;

crypto/cms/cms_smime.c:104:5: Loop condition is true. Entering loop body
102.           if (tmpout && (BIO_write(tmpout, buf, i) != i))
103.               goto err;
104.       }
           ^
105.   
106.       if (flags & CMS_TEXT) {

crypto/cms/cms_smime.c:91:9: 
89.       /* Read all content through chain to process digest, decrypt etc */
90.       for (;;) {
91. >         i = BIO_read(in, buf, sizeof(buf));
92.           if (i <= 0) {
93.               if (BIO_method_type(in) == BIO_TYPE_CIPHER) {

crypto/bio/bio_lib.c:188:1: start of procedure BIO_read()
  186.   }
  187.   
  188. > int BIO_read(BIO *b, void *out, int outl)
  189.   {
  190.       int i;

crypto/bio/bio_lib.c:193:10: Taking false branch
  191.       long (*cb) (BIO *, int, const char *, int, long, long);
  192.   
  193.       if ((b == NULL) || (b->method == NULL) || (b->method->bread == NULL)) {
                  ^
  194.           BIOerr(BIO_F_BIO_READ, BIO_R_UNSUPPORTED_METHOD);
  195.           return (-2);

crypto/bio/bio_lib.c:193:25: Taking false branch
  191.       long (*cb) (BIO *, int, const char *, int, long, long);
  192.   
  193.       if ((b == NULL) || (b->method == NULL) || (b->method->bread == NULL)) {
                                 ^
  194.           BIOerr(BIO_F_BIO_READ, BIO_R_UNSUPPORTED_METHOD);
  195.           return (-2);

crypto/bio/bio_lib.c:193:48: Taking false branch
  191.       long (*cb) (BIO *, int, const char *, int, long, long);
  192.   
  193.       if ((b == NULL) || (b->method == NULL) || (b->method->bread == NULL)) {
                                                        ^
  194.           BIOerr(BIO_F_BIO_READ, BIO_R_UNSUPPORTED_METHOD);
  195.           return (-2);

crypto/bio/bio_lib.c:198:5: 
  196.       }
  197.   
  198. >     cb = b->callback;
  199.       if ((cb != NULL) &&
  200.           ((i = (int)cb(b, BIO_CB_READ, out, outl, 0L, 1L)) <= 0))

crypto/bio/bio_lib.c:199:10: Taking false branch
  197.   
  198.       cb = b->callback;
  199.       if ((cb != NULL) &&
                  ^
  200.           ((i = (int)cb(b, BIO_CB_READ, out, outl, 0L, 1L)) <= 0))
  201.           return (i);

crypto/bio/bio_lib.c:203:10: Taking true branch
  201.           return (i);
  202.   
  203.       if (!b->init) {
                  ^
  204.           BIOerr(BIO_F_BIO_READ, BIO_R_UNINITIALIZED);
  205.           return (-2);

crypto/bio/bio_lib.c:204:9: Skipping ERR_put_error(): empty list of specs
  202.   
  203.       if (!b->init) {
  204.           BIOerr(BIO_F_BIO_READ, BIO_R_UNINITIALIZED);
                 ^
  205.           return (-2);
  206.       }

crypto/bio/bio_lib.c:205:9: 
  203.       if (!b->init) {
  204.           BIOerr(BIO_F_BIO_READ, BIO_R_UNINITIALIZED);
  205. >         return (-2);
  206.       }
  207.   

crypto/bio/bio_lib.c:216:1: return from a call to BIO_read
  214.           i = (int)cb(b, BIO_CB_READ | BIO_CB_RETURN, out, outl, 0L, (long)i);
  215.       return (i);
  216. > }
  217.   
  218.   int BIO_write(BIO *b, const void *in, int inl)

crypto/cms/cms_smime.c:92:13: Taking true branch
90.       for (;;) {
91.           i = BIO_read(in, buf, sizeof(buf));
92.           if (i <= 0) {
                  ^
93.               if (BIO_method_type(in) == BIO_TYPE_CIPHER) {
94.                   if (!BIO_get_cipher_status(in))

crypto/cms/cms_smime.c:93:17: 
91.           i = BIO_read(in, buf, sizeof(buf));
92.           if (i <= 0) {
93. >             if (BIO_method_type(in) == BIO_TYPE_CIPHER) {
94.                   if (!BIO_get_cipher_status(in))
95.                       goto err;

crypto/bio/bio_lib.c:183:1: start of procedure BIO_method_type()
  181.   }
  182.   
  183. > int BIO_method_type(const BIO *b)
  184.   {
  185.       return b->method->type;

crypto/bio/bio_lib.c:185:5: 
  183.   int BIO_method_type(const BIO *b)
  184.   {
  185. >     return b->method->type;
  186.   }
  187.   

crypto/bio/bio_lib.c:186:1: return from a call to BIO_method_type
  184.   {
  185.       return b->method->type;
  186. > }
  187.   
  188.   int BIO_read(BIO *b, void *out, int outl)

crypto/cms/cms_smime.c:93:17: Taking false branch
91.           i = BIO_read(in, buf, sizeof(buf));
92.           if (i <= 0) {
93.               if (BIO_method_type(in) == BIO_TYPE_CIPHER) {
                      ^
94.                   if (!BIO_get_cipher_status(in))
95.                       goto err;

crypto/cms/cms_smime.c:97:17: Taking true branch
95.                       goto err;
96.               }
97.               if (i < 0)
                       ^
98.                   goto err;
99.               break;

crypto/cms/cms_smime.c:115:2: 
113.       r = 1;
114.   
115. >  err:
116.       if (tmpout != out)
117.           BIO_free(tmpout);

crypto/cms/cms_smime.c:116:9: Taking true branch
114.   
115.    err:
116.       if (tmpout != out)
               ^
117.           BIO_free(tmpout);
118.       return r;

crypto/cms/cms_smime.c:117:9: 
115.    err:
116.       if (tmpout != out)
117. >         BIO_free(tmpout);
118.       return r;
119.   

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.   #ifdef REF_PRINT
  114.       REF_PRINT("BIO", a);

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:116:9: Taking false branch
  114.       REF_PRINT("BIO", a);
  115.   #endif
  116.       if (i > 0)
                 ^
  117.           return (1);
  118.   #ifdef REF_CHECK

crypto/bio/bio_lib.c:124:10: Taking true branch
  122.       }
  123.   #endif
  124.       if ((a->callback != NULL) &&
                  ^
  125.           ((i = (int)a->callback(a, BIO_CB_FREE, NULL, 0, 0L, 1L)) <= 0))
  126.           return (i);

crypto/bio/bio_lib.c:125:10: Taking true branch
  123.   #endif
  124.       if ((a->callback != NULL) &&
  125.           ((i = (int)a->callback(a, BIO_CB_FREE, NULL, 0, 0L, 1L)) <= 0))
                  ^
  126.           return (i);
  127.   

crypto/bio/bio_lib.c:126:9: 
  124.       if ((a->callback != NULL) &&
  125.           ((i = (int)a->callback(a, BIO_CB_FREE, NULL, 0, 0L, 1L)) <= 0))
  126. >         return (i);
  127.   
  128.       CRYPTO_free_ex_data(CRYPTO_EX_INDEX_BIO, a, &a->ex_data);

crypto/bio/bio_lib.c:134:1: return from a call to BIO_free
  132.       OPENSSL_free(a);
  133.       return (1);
  134. > }
  135.   
  136.   void BIO_vfree(BIO *a)

static int cms_copy_content(BIO *out, BIO *in, unsigned int flags)
{
    unsigned char buf[4096];
    int r = 0, i;
    BIO *tmpout;
    tmpout = cms_get_text_bio(out, flags);
    if (tmpout == NULL) {
        CMSerr(CMS_F_CMS_COPY_CONTENT, ERR_R_MALLOC_FAILURE);
        goto err;
    }
    for (;;) {
        i = BIO_read(in, buf, sizeof(buf));
        if (i <= 0) {
            if (BIO_method_type(in) == BIO_TYPE_CIPHER) {
                if (!BIO_get_cipher_status(in))
                    goto err;
            }
            if (i < 0)
                goto err;
            break;
        }
        if (tmpout && (BIO_write(tmpout, buf, i) != i))
            goto err;
    }
    if (flags & CMS_TEXT) {
        if (!SMIME_text(tmpout, out)) {
            CMSerr(CMS_F_CMS_COPY_CONTENT, CMS_R_SMIME_TEXT_ERROR);
            goto err;
        }
    }
    r = 1;
 err:
    if (tmpout != out)
        BIO_free(tmpout);
    return r;
}
['static int cms_copy_content(BIO *out, BIO *in, unsigned int flags)\n{\n    unsigned char buf[4096];\n    int r = 0, i;\n    BIO *tmpout;\n    tmpout = cms_get_text_bio(out, flags);\n    if (tmpout == NULL) {\n        CMSerr(CMS_F_CMS_COPY_CONTENT, ERR_R_MALLOC_FAILURE);\n        goto err;\n    }\n    for (;;) {\n        i = BIO_read(in, buf, sizeof(buf));\n        if (i <= 0) {\n            if (BIO_method_type(in) == BIO_TYPE_CIPHER) {\n                if (!BIO_get_cipher_status(in))\n                    goto err;\n            }\n            if (i < 0)\n                goto err;\n            break;\n        }\n        if (tmpout && (BIO_write(tmpout, buf, i) != i))\n            goto err;\n    }\n    if (flags & CMS_TEXT) {\n        if (!SMIME_text(tmpout, out)) {\n            CMSerr(CMS_F_CMS_COPY_CONTENT, CMS_R_SMIME_TEXT_ERROR);\n            goto err;\n        }\n    }\n    r = 1;\n err:\n    if (tmpout != out)\n        BIO_free(tmpout);\n    return r;\n}', 'static BIO *cms_get_text_bio(BIO *out, unsigned int flags)\n{\n    BIO *rbio;\n    if (out == NULL)\n        rbio = BIO_new(BIO_s_null());\n    else if (flags & CMS_TEXT) {\n        rbio = BIO_new(BIO_s_mem());\n        BIO_set_mem_eof_return(rbio, 0);\n    } else\n        rbio = out;\n    return rbio;\n}', 'BIO_METHOD *BIO_s_null(void)\n{\n    return (&null_method);\n}', 'BIO *BIO_new(BIO_METHOD *method)\n{\n    BIO *ret = OPENSSL_malloc(sizeof(*ret));\n    if (ret == NULL) {\n        BIOerr(BIO_F_BIO_NEW, ERR_R_MALLOC_FAILURE);\n        return (NULL);\n    }\n    if (!BIO_set(ret, method)) {\n        OPENSSL_free(ret);\n        ret = NULL;\n    }\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}', 'int BIO_read(BIO *b, void *out, int outl)\n{\n    int i;\n    long (*cb) (BIO *, int, const char *, int, long, long);\n    if ((b == NULL) || (b->method == NULL) || (b->method->bread == NULL)) {\n        BIOerr(BIO_F_BIO_READ, BIO_R_UNSUPPORTED_METHOD);\n        return (-2);\n    }\n    cb = b->callback;\n    if ((cb != NULL) &&\n        ((i = (int)cb(b, BIO_CB_READ, out, outl, 0L, 1L)) <= 0))\n        return (i);\n    if (!b->init) {\n        BIOerr(BIO_F_BIO_READ, BIO_R_UNINITIALIZED);\n        return (-2);\n    }\n    i = b->method->bread(b, out, outl);\n    if (i > 0)\n        b->num_read += (uint64_t)i;\n    if (cb != NULL)\n        i = (int)cb(b, BIO_CB_READ | BIO_CB_RETURN, out, outl, 0L, (long)i);\n    return (i);\n}', 'int BIO_method_type(const BIO *b)\n{\n    return b->method->type;\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#ifdef REF_PRINT\n    REF_PRINT("BIO", a);\n#endif\n    if (i > 0)\n        return (1);\n#ifdef REF_CHECK\n    if (i < 0) {\n        fprintf(stderr, "BIO_free, bad reference count\\n");\n        abort();\n    }\n#endif\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}']