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


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

crypto/conf/conf_mod.c:389:32: global variable `initialized_modules` accessed here
  387.   {
  388.       CONF_IMODULE *imod;
  389.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
                                        ^
  390.           imod = sk_CONF_IMODULE_pop(initialized_modules);
  391.           module_finish(imod);

crypto/conf/conf_mod.c:390:16: passed as argument to `sk_CONF_IMODULE_pop`
  388.       CONF_IMODULE *imod;
  389.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
  390.           imod = sk_CONF_IMODULE_pop(initialized_modules);
                        ^
  391.           module_finish(imod);
  392.       }

crypto/conf/conf_mod.c:390:16: return from call to `sk_CONF_IMODULE_pop`
  388.       CONF_IMODULE *imod;
  389.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
  390.           imod = sk_CONF_IMODULE_pop(initialized_modules);
                        ^
  391.           module_finish(imod);
  392.       }

crypto/conf/conf_mod.c:390:9: assigned
  388.       CONF_IMODULE *imod;
  389.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
  390.           imod = sk_CONF_IMODULE_pop(initialized_modules);
                 ^
  391.           module_finish(imod);
  392.       }

crypto/conf/conf_mod.c:391:9: when calling `module_finish` here
  389.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
  390.           imod = sk_CONF_IMODULE_pop(initialized_modules);
  391.           module_finish(imod);
                 ^
  392.       }
  393.       sk_CONF_IMODULE_free(initialized_modules);

crypto/conf/conf_mod.c:399:1: parameter `imod` of module_finish
    397.   /* finish a module instance */
    398.   
    399. > static void module_finish(CONF_IMODULE *imod)
    400.   {
    401.       if (!imod)

crypto/conf/conf_mod.c:408:5: when calling `CRYPTO_free` here
    406.       OPENSSL_free(imod->name);
    407.       OPENSSL_free(imod->value);
    408.       OPENSSL_free(imod);
               ^
    409.   }
    410.   

crypto/mem.c:286:1: parameter `str` of CRYPTO_free
      284.   }
      285.   
      286. > void CRYPTO_free(void *str, const char *file, int line)
      287.   {
      288.       INCREMENT(free_count);

crypto/mem.c:303:5: was invalidated by call to `free()`
      301.       }
      302.   #else
      303.       free(str);
                 ^
      304.   #endif
      305.   }

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

crypto/conf/conf_mod.c:389:32: global variable `initialized_modules` accessed here
  387.   {
  388.       CONF_IMODULE *imod;
  389.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
                                        ^
  390.           imod = sk_CONF_IMODULE_pop(initialized_modules);
  391.           module_finish(imod);

crypto/conf/conf_mod.c:390:16: passed as argument to `sk_CONF_IMODULE_pop`
  388.       CONF_IMODULE *imod;
  389.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
  390.           imod = sk_CONF_IMODULE_pop(initialized_modules);
                        ^
  391.           module_finish(imod);
  392.       }

crypto/conf/conf_mod.c:390:16: return from call to `sk_CONF_IMODULE_pop`
  388.       CONF_IMODULE *imod;
  389.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
  390.           imod = sk_CONF_IMODULE_pop(initialized_modules);
                        ^
  391.           module_finish(imod);
  392.       }

crypto/conf/conf_mod.c:390:9: assigned
  388.       CONF_IMODULE *imod;
  389.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
  390.           imod = sk_CONF_IMODULE_pop(initialized_modules);
                 ^
  391.           module_finish(imod);
  392.       }

crypto/conf/conf_mod.c:391:9: when calling `module_finish` here
  389.       while (sk_CONF_IMODULE_num(initialized_modules) > 0) {
  390.           imod = sk_CONF_IMODULE_pop(initialized_modules);
  391.           module_finish(imod);
                 ^
  392.       }
  393.       sk_CONF_IMODULE_free(initialized_modules);

crypto/conf/conf_mod.c:399:1: parameter `imod` of module_finish
    397.   /* finish a module instance */
    398.   
    399. > static void module_finish(CONF_IMODULE *imod)
    400.   {
    401.       if (!imod)

crypto/conf/conf_mod.c:408:5: when calling `CRYPTO_free` here
    406.       OPENSSL_free(imod->name);
    407.       OPENSSL_free(imod->value);
    408.       OPENSSL_free(imod);
               ^
    409.   }
    410.   

crypto/mem.c:286:1: parameter `str` of CRYPTO_free
      284.   }
      285.   
      286. > void CRYPTO_free(void *str, const char *file, int line)
      287.   {
      288.       INCREMENT(free_count);

crypto/mem.c:303:5: invalid access occurs here
      301.       }
      302.   #else
      303.       free(str);
                 ^
      304.   #endif
      305.   }

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}']