apps/engine.c:63: error: MEMORY_LEAK
  memory dynamically allocated to `*buf` by call to `app_malloc()` at line 53, column 16 is not reachable after line 63, column 13.
Showing all 37 steps of the trace


apps/engine.c:49:1: start of procedure append_buf()
47.   };
48.   
49. > static int append_buf(char **buf, int *size, const char *s)
50.   {
51.       if (*buf == NULL) {

apps/engine.c:51:9: Taking true branch
49.   static int append_buf(char **buf, int *size, const char *s)
50.   {
51.       if (*buf == NULL) {
              ^
52.           *size = 256;
53.           *buf = app_malloc(*size, "engine buffer");

apps/engine.c:52:9: 
50.   {
51.       if (*buf == NULL) {
52. >         *size = 256;
53.           *buf = app_malloc(*size, "engine buffer");
54.           **buf = '\0';

apps/engine.c:53:9: 
51.       if (*buf == NULL) {
52.           *size = 256;
53. >         *buf = app_malloc(*size, "engine buffer");
54.           **buf = '\0';
55.       }

apps/apps.c:935:1: start of procedure app_malloc()
  933.   }
  934.   
  935. > void* app_malloc(int sz, const char *what)
  936.   {
  937.       void *vp = OPENSSL_malloc(sz);

apps/apps.c:937:5: 
  935.   void* app_malloc(int sz, const char *what)
  936.   {
  937. >     void *vp = OPENSSL_malloc(sz);
  938.   
  939.       if (vp == NULL) {

crypto/mem.c:166:1: start of procedure CRYPTO_malloc()
    164.   #endif
    165.   
    166. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    167.   {
    168.       void *ret = NULL;

crypto/mem.c:168:5: 
    166.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    167.   {
    168. >     void *ret = NULL;
    169.   
    170.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:170:9: Taking false branch
    168.       void *ret = NULL;
    169.   
    170.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                   ^
    171.           return malloc_impl(num, file, line);
    172.   

crypto/mem.c:173:9: Taking false branch
    171.           return malloc_impl(num, file, line);
    172.   
    173.       if (num == 0)
                   ^
    174.           return NULL;
    175.   

crypto/mem.c:177:5: 
    175.   
    176.       FAILTEST();
    177. >     allow_customize = 0;
    178.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
    179.       if (call_malloc_debug) {

crypto/mem.c:187:5: 
    185.       }
    186.   #else
    187. >     osslargused(file); osslargused(line);
    188.       ret = malloc(num);
    189.   #endif

crypto/mem.c:187:24: 
    185.       }
    186.   #else
    187. >     osslargused(file); osslargused(line);
    188.       ret = malloc(num);
    189.   #endif

crypto/mem.c:188:5: 
    186.   #else
    187.       osslargused(file); osslargused(line);
    188. >     ret = malloc(num);
    189.   #endif
    190.   

crypto/mem.c:191:5: 
    189.   #endif
    190.   
    191. >     return ret;
    192.   }
    193.   

crypto/mem.c:192:1: return from a call to CRYPTO_malloc
    190.   
    191.       return ret;
    192. > }
    193.   
    194.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

apps/apps.c:939:9: Taking false branch
  937.       void *vp = OPENSSL_malloc(sz);
  938.   
  939.       if (vp == NULL) {
                 ^
  940.           BIO_printf(bio_err, "%s: Could not allocate %d bytes for %s\n",
  941.                   opt_getprog(), sz, what);

apps/apps.c:945:5: 
  943.           exit(1);
  944.       }
  945. >     return vp;
  946.   }
  947.   

apps/apps.c:946:1: return from a call to app_malloc
  944.       }
  945.       return vp;
  946. > }
  947.   
  948.   /*

apps/engine.c:54:9: 
52.           *size = 256;
53.           *buf = app_malloc(*size, "engine buffer");
54. >         **buf = '\0';
55.       }
56.   

apps/engine.c:57:9: Taking true branch
55.       }
56.   
57.       if (strlen(*buf) + strlen(s) >= (unsigned int)*size) {
              ^
58.           char *tmp;
59.           *size += 256;

apps/engine.c:59:9: 
57.       if (strlen(*buf) + strlen(s) >= (unsigned int)*size) {
58.           char *tmp;
59. >         *size += 256;
60.           tmp = OPENSSL_realloc(*buf, *size);
61.           if (tmp == NULL) {

apps/engine.c:60:9: 
58.           char *tmp;
59.           *size += 256;
60. >         tmp = OPENSSL_realloc(*buf, *size);
61.           if (tmp == NULL) {
62.               OPENSSL_free(*buf);

crypto/mem.c:204:1: start of procedure CRYPTO_realloc()
  202.   }
  203.   
  204. > void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)
  205.   {
  206.       if (realloc_impl != NULL && realloc_impl != &CRYPTO_realloc)

crypto/mem.c:206:9: Taking true branch
  204.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)
  205.   {
  206.       if (realloc_impl != NULL && realloc_impl != &CRYPTO_realloc)
                 ^
  207.           return realloc_impl(str, num, file, line);
  208.   

crypto/mem.c:206:33: Taking true branch
  204.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)
  205.   {
  206.       if (realloc_impl != NULL && realloc_impl != &CRYPTO_realloc)
                                         ^
  207.           return realloc_impl(str, num, file, line);
  208.   

crypto/mem.c:207:9: Skipping __function_pointer__(): unresolved function pointer
  205.   {
  206.       if (realloc_impl != NULL && realloc_impl != &CRYPTO_realloc)
  207.           return realloc_impl(str, num, file, line);
                 ^
  208.   
  209.       FAILTEST();

crypto/mem.c:232:1: return from a call to CRYPTO_realloc
  230.       return realloc(str, num);
  231.   
  232. > }
  233.   
  234.   void *CRYPTO_clear_realloc(void *str, size_t old_len, size_t num,

apps/engine.c:61:13: Taking true branch
59.           *size += 256;
60.           tmp = OPENSSL_realloc(*buf, *size);
61.           if (tmp == NULL) {
                  ^
62.               OPENSSL_free(*buf);
63.               *buf = NULL;

apps/engine.c:62:13: 
60.           tmp = OPENSSL_realloc(*buf, *size);
61.           if (tmp == NULL) {
62. >             OPENSSL_free(*buf);
63.               *buf = NULL;
64.               return 0;

crypto/mem.c:261:1: start of procedure CRYPTO_free()
  259.   }
  260.   
  261. > void CRYPTO_free(void *str, const char *file, int line)
  262.   {
  263.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:263:9: Taking true branch
  261.   void CRYPTO_free(void *str, const char *file, int line)
  262.   {
  263.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                 ^
  264.           free_impl(str, file, line);
  265.           return;

crypto/mem.c:263:30: Taking true branch
  261.   void CRYPTO_free(void *str, const char *file, int line)
  262.   {
  263.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                      ^
  264.           free_impl(str, file, line);
  265.           return;

crypto/mem.c:264:9: Skipping __function_pointer__(): unresolved function pointer
  262.   {
  263.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
  264.           free_impl(str, file, line);
                 ^
  265.           return;
  266.       }

crypto/mem.c:265:9: 
  263.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
  264.           free_impl(str, file, line);
  265. >         return;
  266.       }
  267.   

crypto/mem.c:279:1: return from a call to CRYPTO_free
  277.       free(str);
  278.   #endif
  279. > }
  280.   
  281.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

apps/engine.c:63:13: 
61.           if (tmp == NULL) {
62.               OPENSSL_free(*buf);
63. >             *buf = NULL;
64.               return 0;
65.           }

static int append_buf(char **buf, int *size, const char *s)
{
    if (*buf == NULL) {
        *size = 256;
        *buf = app_malloc(*size, "engine buffer");
        **buf = '\0';
    }
    if (strlen(*buf) + strlen(s) >= (unsigned int)*size) {
        char *tmp;
        *size += 256;
        tmp = OPENSSL_realloc(*buf, *size);
        if (tmp == NULL) {
            OPENSSL_free(*buf);
            *buf = NULL;
            return 0;
        }
        *buf = tmp;
    }
    if (**buf != '\0')
        OPENSSL_strlcat(*buf, ", ", *size);
    OPENSSL_strlcat(*buf, s, *size);
    return 1;
}
['static int append_buf(char **buf, int *size, const char *s)\n{\n    if (*buf == NULL) {\n        *size = 256;\n        *buf = app_malloc(*size, "engine buffer");\n        **buf = \'\\0\';\n    }\n    if (strlen(*buf) + strlen(s) >= (unsigned int)*size) {\n        char *tmp;\n        *size += 256;\n        tmp = OPENSSL_realloc(*buf, *size);\n        if (tmp == NULL) {\n            OPENSSL_free(*buf);\n            *buf = NULL;\n            return 0;\n        }\n        *buf = tmp;\n    }\n    if (**buf != \'\\0\')\n        OPENSSL_strlcat(*buf, ", ", *size);\n    OPENSSL_strlcat(*buf, s, *size);\n    return 1;\n}', 'void* app_malloc(int sz, const char *what)\n{\n    void *vp = OPENSSL_malloc(sz);\n    if (vp == NULL) {\n        BIO_printf(bio_err, "%s: Could not allocate %d bytes for %s\\n",\n                opt_getprog(), sz, what);\n        ERR_print_errors(bio_err);\n        exit(1);\n    }\n    return vp;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)\n        return malloc_impl(num, file, line);\n    if (num == 0)\n        return NULL;\n    FAILTEST();\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    osslargused(file); osslargused(line);\n    ret = malloc(num);\n#endif\n    return ret;\n}', 'void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)\n{\n    if (realloc_impl != NULL && realloc_impl != &CRYPTO_realloc)\n        return realloc_impl(str, num, file, line);\n    FAILTEST();\n    if (str == NULL)\n        return CRYPTO_malloc(num, file, line);\n    if (num == 0) {\n        CRYPTO_free(str, file, line);\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    osslargused(file); osslargused(line);\n#endif\n    return realloc(str, num);\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}']