crypto/conf/conf_mod.c:437: error: USE_AFTER_FREE
  call to `module_finish()` eventually accesses memory that was invalidated by call to `free()` on line 437 indirectly during the call to `module_finish()`.
Showing all 40 steps of the trace


crypto/conf/conf_mod.c:435:32: invalidation part of the trace starts here
433.   {
434.       CONF_IMODULE *imod;
435.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
                                      ^
436.           imod = sk_CONF_IMODULE_pop(initialized_modules);
437.           module_finish(imod);

crypto/conf/conf_mod.c:435:32: global variable `initialized_modules` accessed here
  433.   {
  434.       CONF_IMODULE *imod;
  435.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
                                        ^
  436.           imod = sk_CONF_IMODULE_pop(initialized_modules);
  437.           module_finish(imod);

crypto/conf/conf_mod.c:436:16: passed as argument to `sk_CONF_IMODULE_pop`
  434.       CONF_IMODULE *imod;
  435.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
  436.           imod = sk_CONF_IMODULE_pop(initialized_modules);
                        ^
  437.           module_finish(imod);
  438.       }

include/openssl/conf.h:105:1: parameter `sk` of sk_CONF_IMODULE_pop
    103.   
    104.   DEFINE_STACK_OF(CONF_MODULE)
    105. > DEFINE_STACK_OF(CONF_IMODULE)
    106.   
    107.   /* DSO module function typedefs */

include/openssl/conf.h:105:1: passed as argument to `sk_pop`
    103.   
    104.   DEFINE_STACK_OF(CONF_MODULE)
    105. > DEFINE_STACK_OF(CONF_IMODULE)
    106.   
    107.   /* DSO module function typedefs */

crypto/stack/stack.c:277:1: parameter `st` of sk_pop
      275.   }
      276.   
      277. > void *sk_pop(_STACK *st)
      278.   {
      279.       if (st == NULL)

crypto/stack/stack.c:283:13: passed as argument to `sk_delete`
      281.       if (st->num <= 0)
      282.           return (NULL);
      283.       return (sk_delete(st, st->num - 1));
                         ^
      284.   }
      285.   

crypto/stack/stack.c:202:1: parameter `st` of sk_delete
        200.   }
        201.   
        202. > void *sk_delete(_STACK *st, int loc)
        203.   {
        204.       char *ret;

crypto/stack/stack.c:214:13: assigned
        212.           j = st->num - 1;
        213.           for (i = loc; i < j; i++)
        214.               st->data[i] = st->data[i + 1];
                           ^
        215.           /*
        216.            * In theory memcpy is not safe for this memcpy( &(st->data[loc]),

crypto/stack/stack.c:283:13: return from call to `sk_delete`
      281.       if (st->num <= 0)
      282.           return (NULL);
      283.       return (sk_delete(st, st->num - 1));
                         ^
      284.   }
      285.   

include/openssl/conf.h:105:1: return from call to `sk_pop`
    103.   
    104.   DEFINE_STACK_OF(CONF_MODULE)
    105. > DEFINE_STACK_OF(CONF_IMODULE)
    106.   
    107.   /* DSO module function typedefs */

crypto/conf/conf_mod.c:436:16: return from call to `sk_CONF_IMODULE_pop`
  434.       CONF_IMODULE *imod;
  435.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
  436.           imod = sk_CONF_IMODULE_pop(initialized_modules);
                        ^
  437.           module_finish(imod);
  438.       }

crypto/conf/conf_mod.c:436:16: passed as argument to `sk_CONF_IMODULE_pop`
  434.       CONF_IMODULE *imod;
  435.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
  436.           imod = sk_CONF_IMODULE_pop(initialized_modules);
                        ^
  437.           module_finish(imod);
  438.       }

crypto/conf/conf_mod.c:436:16: return from call to `sk_CONF_IMODULE_pop`
  434.       CONF_IMODULE *imod;
  435.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
  436.           imod = sk_CONF_IMODULE_pop(initialized_modules);
                        ^
  437.           module_finish(imod);
  438.       }

crypto/conf/conf_mod.c:436:9: assigned
  434.       CONF_IMODULE *imod;
  435.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
  436.           imod = sk_CONF_IMODULE_pop(initialized_modules);
                 ^
  437.           module_finish(imod);
  438.       }

crypto/conf/conf_mod.c:437:9: when calling `module_finish` here
  435.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
  436.           imod = sk_CONF_IMODULE_pop(initialized_modules);
  437.           module_finish(imod);
                 ^
  438.       }
  439.       sk_CONF_IMODULE_free(initialized_modules);

crypto/conf/conf_mod.c:445:1: parameter `imod` of module_finish
    443.   /* finish a module instance */
    444.   
    445. > static void module_finish(CONF_IMODULE *imod)
    446.   {
    447.       if (!imod)

crypto/conf/conf_mod.c:454:5: when calling `CRYPTO_free` here
    452.       OPENSSL_free(imod->name);
    453.       OPENSSL_free(imod->value);
    454.       OPENSSL_free(imod);
               ^
    455.   }
    456.   

crypto/mem.c:211:1: parameter `str` of CRYPTO_free
      209.   }
      210.   
      211. > void CRYPTO_free(void *str, const char *file, int line)
      212.   {
      213.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:227:5: was invalidated by call to `free()`
      225.       }
      226.   #else
      227.       free(str);
                 ^
      228.   #endif
      229.   }

crypto/conf/conf_mod.c:435:32: use-after-lifetime part of the trace starts here
433.   {
434.       CONF_IMODULE *imod;
435.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
                                      ^
436.           imod = sk_CONF_IMODULE_pop(initialized_modules);
437.           module_finish(imod);

crypto/conf/conf_mod.c:435:32: global variable `initialized_modules` accessed here
  433.   {
  434.       CONF_IMODULE *imod;
  435.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
                                        ^
  436.           imod = sk_CONF_IMODULE_pop(initialized_modules);
  437.           module_finish(imod);

crypto/conf/conf_mod.c:436:16: passed as argument to `sk_CONF_IMODULE_pop`
  434.       CONF_IMODULE *imod;
  435.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
  436.           imod = sk_CONF_IMODULE_pop(initialized_modules);
                        ^
  437.           module_finish(imod);
  438.       }

include/openssl/conf.h:105:1: parameter `sk` of sk_CONF_IMODULE_pop
    103.   
    104.   DEFINE_STACK_OF(CONF_MODULE)
    105. > DEFINE_STACK_OF(CONF_IMODULE)
    106.   
    107.   /* DSO module function typedefs */

include/openssl/conf.h:105:1: passed as argument to `sk_pop`
    103.   
    104.   DEFINE_STACK_OF(CONF_MODULE)
    105. > DEFINE_STACK_OF(CONF_IMODULE)
    106.   
    107.   /* DSO module function typedefs */

crypto/stack/stack.c:277:1: parameter `st` of sk_pop
      275.   }
      276.   
      277. > void *sk_pop(_STACK *st)
      278.   {
      279.       if (st == NULL)

crypto/stack/stack.c:283:13: passed as argument to `sk_delete`
      281.       if (st->num <= 0)
      282.           return (NULL);
      283.       return (sk_delete(st, st->num - 1));
                         ^
      284.   }
      285.   

crypto/stack/stack.c:202:1: parameter `st` of sk_delete
        200.   }
        201.   
        202. > void *sk_delete(_STACK *st, int loc)
        203.   {
        204.       char *ret;

crypto/stack/stack.c:214:13: assigned
        212.           j = st->num - 1;
        213.           for (i = loc; i < j; i++)
        214.               st->data[i] = st->data[i + 1];
                           ^
        215.           /*
        216.            * In theory memcpy is not safe for this memcpy( &(st->data[loc]),

crypto/stack/stack.c:283:13: return from call to `sk_delete`
      281.       if (st->num <= 0)
      282.           return (NULL);
      283.       return (sk_delete(st, st->num - 1));
                         ^
      284.   }
      285.   

include/openssl/conf.h:105:1: return from call to `sk_pop`
    103.   
    104.   DEFINE_STACK_OF(CONF_MODULE)
    105. > DEFINE_STACK_OF(CONF_IMODULE)
    106.   
    107.   /* DSO module function typedefs */

crypto/conf/conf_mod.c:436:16: return from call to `sk_CONF_IMODULE_pop`
  434.       CONF_IMODULE *imod;
  435.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
  436.           imod = sk_CONF_IMODULE_pop(initialized_modules);
                        ^
  437.           module_finish(imod);
  438.       }

crypto/conf/conf_mod.c:436:16: passed as argument to `sk_CONF_IMODULE_pop`
  434.       CONF_IMODULE *imod;
  435.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
  436.           imod = sk_CONF_IMODULE_pop(initialized_modules);
                        ^
  437.           module_finish(imod);
  438.       }

crypto/conf/conf_mod.c:436:16: return from call to `sk_CONF_IMODULE_pop`
  434.       CONF_IMODULE *imod;
  435.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
  436.           imod = sk_CONF_IMODULE_pop(initialized_modules);
                        ^
  437.           module_finish(imod);
  438.       }

crypto/conf/conf_mod.c:436:9: assigned
  434.       CONF_IMODULE *imod;
  435.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
  436.           imod = sk_CONF_IMODULE_pop(initialized_modules);
                 ^
  437.           module_finish(imod);
  438.       }

crypto/conf/conf_mod.c:437:9: when calling `module_finish` here
  435.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
  436.           imod = sk_CONF_IMODULE_pop(initialized_modules);
  437.           module_finish(imod);
                 ^
  438.       }
  439.       sk_CONF_IMODULE_free(initialized_modules);

crypto/conf/conf_mod.c:445:1: parameter `imod` of module_finish
    443.   /* finish a module instance */
    444.   
    445. > static void module_finish(CONF_IMODULE *imod)
    446.   {
    447.       if (!imod)

crypto/conf/conf_mod.c:454:5: when calling `CRYPTO_free` here
    452.       OPENSSL_free(imod->name);
    453.       OPENSSL_free(imod->value);
    454.       OPENSSL_free(imod);
               ^
    455.   }
    456.   

crypto/mem.c:211:1: parameter `str` of CRYPTO_free
      209.   }
      210.   
      211. > void CRYPTO_free(void *str, const char *file, int line)
      212.   {
      213.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:227:5: invalid access occurs here
      225.       }
      226.   #else
      227.       free(str);
                 ^
      228.   #endif
      229.   }

void CRYPTO_free(void *str, const char *file, int line)
{
    if (free_impl != NULL && free_impl != &CRYPTO_free) {
        free_impl(str, file, line);
        return;
    }
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
    if (call_malloc_debug) {
        CRYPTO_mem_debug_free(str, 0, file, line);
        free(str);
        CRYPTO_mem_debug_free(str, 1, file, line);
    } else {
        free(str);
    }
#else
    free(str);
#endif
}
['void CONF_modules_finish(void)\n{\n    CONF_IMODULE *imod;\n    while (sk_CONF_IMODULE_num(initialized_modules) > 0) {\n        imod = sk_CONF_IMODULE_pop(initialized_modules);\n        module_finish(imod);\n    }\n    sk_CONF_IMODULE_free(initialized_modules);\n    initialized_modules = NULL;\n}', 'void *sk_pop(_STACK *st)\n{\n    if (st == NULL)\n        return (NULL);\n    if (st->num <= 0)\n        return (NULL);\n    return (sk_delete(st, st->num - 1));\n}', 'void *sk_delete(_STACK *st, int loc)\n{\n    char *ret;\n    int i, j;\n    if (!st || (loc < 0) || (loc >= st->num))\n        return NULL;\n    ret = st->data[loc];\n    if (loc != st->num - 1) {\n        j = st->num - 1;\n        for (i = loc; i < j; i++)\n            st->data[i] = st->data[i + 1];\n    }\n    st->num--;\n    return (ret);\n}', 'static void module_finish(CONF_IMODULE *imod)\n{\n    if (!imod)\n        return;\n    if (imod->pmod->finish)\n        imod->pmod->finish(imod);\n    imod->pmod->links--;\n    OPENSSL_free(imod->name);\n    OPENSSL_free(imod->value);\n    OPENSSL_free(imod);\n}', 'void CRYPTO_free(void *str, const char *file, int line)\n{\n    if (free_impl != NULL && free_impl != &CRYPTO_free) {\n        free_impl(str, file, line);\n        return;\n    }\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_free(str, 0, file, line);\n        free(str);\n        CRYPTO_mem_debug_free(str, 1, file, line);\n    } else {\n        free(str);\n    }\n#else\n    free(str);\n#endif\n}']