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


crypto/conf/conf_mod.c:393:32: invalidation part of the trace starts here
391.   {
392.       CONF_IMODULE *imod;
393.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
                                      ^
394.           imod = sk_CONF_IMODULE_pop(initialized_modules);
395.           module_finish(imod);

crypto/conf/conf_mod.c:393:32: global variable `initialized_modules` accessed here
  391.   {
  392.       CONF_IMODULE *imod;
  393.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
                                        ^
  394.           imod = sk_CONF_IMODULE_pop(initialized_modules);
  395.           module_finish(imod);

crypto/conf/conf_mod.c:394:16: passed as argument to `sk_CONF_IMODULE_pop`
  392.       CONF_IMODULE *imod;
  393.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
  394.           imod = sk_CONF_IMODULE_pop(initialized_modules);
                        ^
  395.           module_finish(imod);
  396.       }

crypto/conf/conf_mod.c:394:16: return from call to `sk_CONF_IMODULE_pop`
  392.       CONF_IMODULE *imod;
  393.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
  394.           imod = sk_CONF_IMODULE_pop(initialized_modules);
                        ^
  395.           module_finish(imod);
  396.       }

crypto/conf/conf_mod.c:394:9: assigned
  392.       CONF_IMODULE *imod;
  393.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
  394.           imod = sk_CONF_IMODULE_pop(initialized_modules);
                 ^
  395.           module_finish(imod);
  396.       }

crypto/conf/conf_mod.c:395:9: when calling `module_finish` here
  393.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
  394.           imod = sk_CONF_IMODULE_pop(initialized_modules);
  395.           module_finish(imod);
                 ^
  396.       }
  397.       sk_CONF_IMODULE_free(initialized_modules);

crypto/conf/conf_mod.c:403:1: parameter `imod` of module_finish
    401.   /* finish a module instance */
    402.   
    403. > static void module_finish(CONF_IMODULE *imod)
    404.   {
    405.       if (!imod)

crypto/conf/conf_mod.c:412:5: when calling `CRYPTO_free` here
    410.       OPENSSL_free(imod->name);
    411.       OPENSSL_free(imod->value);
    412.       OPENSSL_free(imod);
               ^
    413.   }
    414.   

crypto/mem.c:295:1: parameter `str` of CRYPTO_free
      293.   }
      294.   
      295. > void CRYPTO_free(void *str, const char *file, int line)
      296.   {
      297.       INCREMENT(free_count);

crypto/mem.c:312:5: was invalidated by call to `free()`
      310.       }
      311.   #else
      312.       free(str);
                 ^
      313.   #endif
      314.   }

crypto/conf/conf_mod.c:393:32: use-after-lifetime part of the trace starts here
391.   {
392.       CONF_IMODULE *imod;
393.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
                                      ^
394.           imod = sk_CONF_IMODULE_pop(initialized_modules);
395.           module_finish(imod);

crypto/conf/conf_mod.c:393:32: global variable `initialized_modules` accessed here
  391.   {
  392.       CONF_IMODULE *imod;
  393.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
                                        ^
  394.           imod = sk_CONF_IMODULE_pop(initialized_modules);
  395.           module_finish(imod);

crypto/conf/conf_mod.c:394:16: passed as argument to `sk_CONF_IMODULE_pop`
  392.       CONF_IMODULE *imod;
  393.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
  394.           imod = sk_CONF_IMODULE_pop(initialized_modules);
                        ^
  395.           module_finish(imod);
  396.       }

crypto/conf/conf_mod.c:394:16: return from call to `sk_CONF_IMODULE_pop`
  392.       CONF_IMODULE *imod;
  393.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
  394.           imod = sk_CONF_IMODULE_pop(initialized_modules);
                        ^
  395.           module_finish(imod);
  396.       }

crypto/conf/conf_mod.c:394:9: assigned
  392.       CONF_IMODULE *imod;
  393.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
  394.           imod = sk_CONF_IMODULE_pop(initialized_modules);
                 ^
  395.           module_finish(imod);
  396.       }

crypto/conf/conf_mod.c:395:9: when calling `module_finish` here
  393.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
  394.           imod = sk_CONF_IMODULE_pop(initialized_modules);
  395.           module_finish(imod);
                 ^
  396.       }
  397.       sk_CONF_IMODULE_free(initialized_modules);

crypto/conf/conf_mod.c:403:1: parameter `imod` of module_finish
    401.   /* finish a module instance */
    402.   
    403. > static void module_finish(CONF_IMODULE *imod)
    404.   {
    405.       if (!imod)

crypto/conf/conf_mod.c:412:5: when calling `CRYPTO_free` here
    410.       OPENSSL_free(imod->name);
    411.       OPENSSL_free(imod->value);
    412.       OPENSSL_free(imod);
               ^
    413.   }
    414.   

crypto/mem.c:295:1: parameter `str` of CRYPTO_free
      293.   }
      294.   
      295. > void CRYPTO_free(void *str, const char *file, int line)
      296.   {
      297.       INCREMENT(free_count);

crypto/mem.c:312:5: invalid access occurs here
      310.       }
      311.   #else
      312.       free(str);
                 ^
      313.   #endif
      314.   }

void CRYPTO_free(void *str, const char *file, int line)
{
    INCREMENT(free_count);
    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}', '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    INCREMENT(free_count);\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}']