crypto/engine/eng_lib.c:187: error: MEMORY_LEAK
  memory dynamically allocated by call to `int_cleanup_item()` at line 185, column 12 is not reachable after line 187, column 9.
Showing all 46 steps of the trace


crypto/engine/eng_lib.c:180:1: start of procedure engine_cleanup_add_last()
178.   }
179.   
180. > void engine_cleanup_add_last(ENGINE_CLEANUP_CB *cb)
181.   {
182.       ENGINE_CLEANUP_ITEM *item;

crypto/engine/eng_lib.c:183:10: 
181.   {
182.       ENGINE_CLEANUP_ITEM *item;
183. >     if (!int_cleanup_check(1))
184.           return;
185.       item = int_cleanup_item(cb);

crypto/engine/eng_lib.c:151:1: start of procedure int_cleanup_check()
  149.    */
  150.   static STACK_OF(ENGINE_CLEANUP_ITEM) *cleanup_stack = NULL;
  151. > static int int_cleanup_check(int create)
  152.   {
  153.       if (cleanup_stack)

crypto/engine/eng_lib.c:153:9: Taking true branch
  151.   static int int_cleanup_check(int create)
  152.   {
  153.       if (cleanup_stack)
                 ^
  154.           return 1;
  155.       if (!create)

crypto/engine/eng_lib.c:154:9: 
  152.   {
  153.       if (cleanup_stack)
  154. >         return 1;
  155.       if (!create)
  156.           return 0;

crypto/engine/eng_lib.c:159:1: return from a call to int_cleanup_check
  157.       cleanup_stack = sk_ENGINE_CLEANUP_ITEM_new_null();
  158.       return (cleanup_stack ? 1 : 0);
  159. > }
  160.   
  161.   static ENGINE_CLEANUP_ITEM *int_cleanup_item(ENGINE_CLEANUP_CB *cb)

crypto/engine/eng_lib.c:183:10: Taking false branch
181.   {
182.       ENGINE_CLEANUP_ITEM *item;
183.       if (!int_cleanup_check(1))
                ^
184.           return;
185.       item = int_cleanup_item(cb);

crypto/engine/eng_lib.c:185:5: 
183.       if (!int_cleanup_check(1))
184.           return;
185. >     item = int_cleanup_item(cb);
186.       if (item)
187.           sk_ENGINE_CLEANUP_ITEM_push(cleanup_stack, item);

crypto/engine/eng_lib.c:161:1: start of procedure int_cleanup_item()
  159.   }
  160.   
  161. > static ENGINE_CLEANUP_ITEM *int_cleanup_item(ENGINE_CLEANUP_CB *cb)
  162.   {
  163.       ENGINE_CLEANUP_ITEM *item = OPENSSL_malloc(sizeof(*item));

crypto/engine/eng_lib.c:163:5: 
  161.   static ENGINE_CLEANUP_ITEM *int_cleanup_item(ENGINE_CLEANUP_CB *cb)
  162.   {
  163. >     ENGINE_CLEANUP_ITEM *item = OPENSSL_malloc(sizeof(*item));
  164.       if (item == NULL)
  165.           return 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/engine/eng_lib.c:164:9: Taking false branch
  162.   {
  163.       ENGINE_CLEANUP_ITEM *item = OPENSSL_malloc(sizeof(*item));
  164.       if (item == NULL)
                 ^
  165.           return NULL;
  166.       item->cb = cb;

crypto/engine/eng_lib.c:166:5: 
  164.       if (item == NULL)
  165.           return NULL;
  166. >     item->cb = cb;
  167.       return item;
  168.   }

crypto/engine/eng_lib.c:167:5: 
  165.           return NULL;
  166.       item->cb = cb;
  167. >     return item;
  168.   }
  169.   

crypto/engine/eng_lib.c:168:1: return from a call to int_cleanup_item
  166.       item->cb = cb;
  167.       return item;
  168. > }
  169.   
  170.   void engine_cleanup_add_first(ENGINE_CLEANUP_CB *cb)

crypto/engine/eng_lib.c:186:9: Taking true branch
184.           return;
185.       item = int_cleanup_item(cb);
186.       if (item)
               ^
187.           sk_ENGINE_CLEANUP_ITEM_push(cleanup_stack, item);
188.   }

crypto/engine/eng_lib.c:187:9: 
185.       item = int_cleanup_item(cb);
186.       if (item)
187. >         sk_ENGINE_CLEANUP_ITEM_push(cleanup_stack, item);
188.   }
189.   

crypto/engine/eng_int.h:107:1: start of procedure sk_ENGINE_CLEANUP_ITEM_push()
  105.       ENGINE_CLEANUP_CB *cb;
  106.   } ENGINE_CLEANUP_ITEM;
  107. > DEFINE_STACK_OF(ENGINE_CLEANUP_ITEM)
  108.   void engine_cleanup_add_first(ENGINE_CLEANUP_CB *cb);
  109.   void engine_cleanup_add_last(ENGINE_CLEANUP_CB *cb);

crypto/stack/stack.c:258:1: start of procedure sk_push()
    256.   }
    257.   
    258. > int sk_push(_STACK *st, void *data)
    259.   {
    260.       return (sk_insert(st, data, st->num));

crypto/stack/stack.c:260:5: 
    258.   int sk_push(_STACK *st, void *data)
    259.   {
    260. >     return (sk_insert(st, data, st->num));
    261.   }
    262.   

crypto/stack/stack.c:166:1: start of procedure sk_insert()
      164.   }
      165.   
      166. > int sk_insert(_STACK *st, void *data, int loc)
      167.   {
      168.       char **s;

crypto/stack/stack.c:170:9: Taking false branch
      168.       char **s;
      169.   
      170.       if (st == NULL)
                     ^
      171.           return 0;
      172.       if (st->num_alloc <= st->num + 1) {

crypto/stack/stack.c:172:9: Taking true branch
      170.       if (st == NULL)
      171.           return 0;
      172.       if (st->num_alloc <= st->num + 1) {
                     ^
      173.           s = OPENSSL_realloc((char *)st->data,
      174.                               (unsigned int)sizeof(char *) * st->num_alloc * 2);

crypto/stack/stack.c:173:9: 
      171.           return 0;
      172.       if (st->num_alloc <= st->num + 1) {
      173. >         s = OPENSSL_realloc((char *)st->data,
      174.                               (unsigned int)sizeof(char *) * st->num_alloc * 2);
      175.           if (s == NULL)

crypto/mem.c:165:1: start of procedure CRYPTO_realloc()
        163.   }
        164.   
        165. > void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)
        166.   {
        167.       if (str == NULL)

crypto/mem.c:167:9: Taking true branch
        165.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)
        166.   {
        167.       if (str == NULL)
                       ^
        168.           return CRYPTO_malloc(num, file, line);
        169.   

crypto/mem.c:168:9: 
        166.   {
        167.       if (str == NULL)
        168. >         return CRYPTO_malloc(num, file, line);
        169.   
        170.       if (num == 0) {

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 true branch
          121.       void *ret = NULL;
          122.   
          123.       if (num <= 0)
                         ^
          124.           return NULL;
          125.   

crypto/mem.c:124:9: 
          122.   
          123.       if (num <= 0)
          124. >         return NULL;
          125.   
          126.       allow_customize = 0;

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:190:1: return from a call to CRYPTO_realloc
        188.       return realloc(str, num);
        189.   
        190. > }
        191.   
        192.   void *CRYPTO_clear_realloc(void *str, size_t old_len, size_t num,

crypto/stack/stack.c:175:13: Taking true branch
      173.           s = OPENSSL_realloc((char *)st->data,
      174.                               (unsigned int)sizeof(char *) * st->num_alloc * 2);
      175.           if (s == NULL)
                         ^
      176.               return (0);
      177.           st->data = s;

crypto/stack/stack.c:176:13: 
      174.                               (unsigned int)sizeof(char *) * st->num_alloc * 2);
      175.           if (s == NULL)
      176. >             return (0);
      177.           st->data = s;
      178.           st->num_alloc *= 2;

crypto/stack/stack.c:190:1: return from a call to sk_insert
      188.       st->sorted = 0;
      189.       return (st->num);
      190. > }
      191.   
      192.   void *sk_delete_ptr(_STACK *st, void *p)

crypto/stack/stack.c:261:1: return from a call to sk_push
    259.   {
    260.       return (sk_insert(st, data, st->num));
    261. > }
    262.   
    263.   int sk_unshift(_STACK *st, void *data)

crypto/engine/eng_int.h:107:1: return from a call to sk_ENGINE_CLEANUP_ITEM_push
  105.       ENGINE_CLEANUP_CB *cb;
  106.   } ENGINE_CLEANUP_ITEM;
  107. > DEFINE_STACK_OF(ENGINE_CLEANUP_ITEM)
  108.   void engine_cleanup_add_first(ENGINE_CLEANUP_CB *cb);
  109.   void engine_cleanup_add_last(ENGINE_CLEANUP_CB *cb);

void engine_cleanup_add_last(ENGINE_CLEANUP_CB *cb)
{
    ENGINE_CLEANUP_ITEM *item;
    if (!int_cleanup_check(1))
        return;
    item = int_cleanup_item(cb);
    if (item)
        sk_ENGINE_CLEANUP_ITEM_push(cleanup_stack, item);
}
['void engine_cleanup_add_last(ENGINE_CLEANUP_CB *cb)\n{\n    ENGINE_CLEANUP_ITEM *item;\n    if (!int_cleanup_check(1))\n        return;\n    item = int_cleanup_item(cb);\n    if (item)\n        sk_ENGINE_CLEANUP_ITEM_push(cleanup_stack, item);\n}', 'static int int_cleanup_check(int create)\n{\n    if (cleanup_stack)\n        return 1;\n    if (!create)\n        return 0;\n    cleanup_stack = sk_ENGINE_CLEANUP_ITEM_new_null();\n    return (cleanup_stack ? 1 : 0);\n}', 'static ENGINE_CLEANUP_ITEM *int_cleanup_item(ENGINE_CLEANUP_CB *cb)\n{\n    ENGINE_CLEANUP_ITEM *item = OPENSSL_malloc(sizeof(*item));\n    if (item == NULL)\n        return NULL;\n    item->cb = cb;\n    return item;\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}', 'DEFINE_STACK_OF(ENGINE_CLEANUP_ITEM)', 'int sk_push(_STACK *st, void *data)\n{\n    return (sk_insert(st, data, st->num));\n}', 'int sk_insert(_STACK *st, void *data, int loc)\n{\n    char **s;\n    if (st == NULL)\n        return 0;\n    if (st->num_alloc <= st->num + 1) {\n        s = OPENSSL_realloc((char *)st->data,\n                            (unsigned int)sizeof(char *) * st->num_alloc * 2);\n        if (s == NULL)\n            return (0);\n        st->data = s;\n        st->num_alloc *= 2;\n    }\n    if ((loc >= (int)st->num) || (loc < 0))\n        st->data[st->num] = data;\n    else {\n        memmove(&(st->data[loc + 1]),\n                &(st->data[loc]), sizeof(char *) * (st->num - loc));\n        st->data[loc] = data;\n    }\n    st->num++;\n    st->sorted = 0;\n    return (st->num);\n}', 'void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)\n{\n    if (str == NULL)\n        return CRYPTO_malloc(num, file, line);\n    if (num == 0) {\n        CRYPTO_free(str);\n        return NULL;\n    }\n    allow_customize = 0;\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        void *ret;\n        CRYPTO_mem_debug_realloc(str, NULL, num, 0, file, line);\n        ret = realloc(str, num);\n        CRYPTO_mem_debug_realloc(str, ret, num, 1, file, line);\n        return ret;\n    }\n#else\n    (void)file;\n    (void)line;\n#endif\n    return realloc(str, num);\n}']