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


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

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

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

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

apps/apps.c:925:1: start of procedure app_malloc()
  923.   }
  924.   
  925. > void* app_malloc(int sz, const char *what)
  926.   {
  927.       void *vp = OPENSSL_malloc(sz);

apps/apps.c:927:5: 
  925.   void* app_malloc(int sz, const char *what)
  926.   {
  927. >     void *vp = OPENSSL_malloc(sz);
  928.   
  929.       if (vp == NULL) {

crypto/mem.c:157:1: start of procedure CRYPTO_malloc()
    155.   #endif
    156.   
    157. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    158.   {
    159.       void *ret = NULL;

crypto/mem.c:159:5: 
    157.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    158.   {
    159. >     void *ret = NULL;
    160.   
    161.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:161:9: Taking false branch
    159.       void *ret = NULL;
    160.   
    161.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                   ^
    162.           return malloc_impl(num, file, line);
    163.   

crypto/mem.c:164:9: Taking false branch
    162.           return malloc_impl(num, file, line);
    163.   
    164.       if (num <= 0)
                   ^
    165.           return NULL;
    166.   

crypto/mem.c:168:5: 
    166.   
    167.       FAILTEST();
    168. >     allow_customize = 0;
    169.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
    170.       if (call_malloc_debug) {

crypto/mem.c:178:5: 
    176.       }
    177.   #else
    178. >     osslargused(file); osslargused(line);
    179.       ret = malloc(num);
    180.   #endif

crypto/mem.c:178:24: 
    176.       }
    177.   #else
    178. >     osslargused(file); osslargused(line);
    179.       ret = malloc(num);
    180.   #endif

crypto/mem.c:179:5: 
    177.   #else
    178.       osslargused(file); osslargused(line);
    179. >     ret = malloc(num);
    180.   #endif
    181.   

crypto/mem.c:182:5: 
    180.   #endif
    181.   
    182. >     return ret;
    183.   }
    184.   

crypto/mem.c:183:1: return from a call to CRYPTO_malloc
    181.   
    182.       return ret;
    183. > }
    184.   
    185.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

apps/apps.c:929:9: Taking false branch
  927.       void *vp = OPENSSL_malloc(sz);
  928.   
  929.       if (vp == NULL) {
                 ^
  930.           BIO_printf(bio_err, "%s: Could not allocate %d bytes for %s\n",
  931.                   opt_getprog(), sz, what);

apps/apps.c:935:5: 
  933.           exit(1);
  934.       }
  935. >     return vp;
  936.   }
  937.   

apps/apps.c:936:1: return from a call to app_malloc
  934.       }
  935.       return vp;
  936. > }
  937.   
  938.   /*

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

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

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

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

crypto/mem.c:195:1: start of procedure CRYPTO_realloc()
  193.   }
  194.   
  195. > void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)
  196.   {
  197.       if (realloc_impl != NULL && realloc_impl != &CRYPTO_realloc)

crypto/mem.c:197:9: Taking true branch
  195.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)
  196.   {
  197.       if (realloc_impl != NULL && realloc_impl != &CRYPTO_realloc)
                 ^
  198.           return realloc_impl(str, num, file, line);
  199.   

crypto/mem.c:197:33: Taking true branch
  195.   void *CRYPTO_realloc(void *str, size_t num, const char *file, int line)
  196.   {
  197.       if (realloc_impl != NULL && realloc_impl != &CRYPTO_realloc)
                                         ^
  198.           return realloc_impl(str, num, file, line);
  199.   

crypto/mem.c:198:9: Skipping __function_pointer__(): unresolved function pointer
  196.   {
  197.       if (realloc_impl != NULL && realloc_impl != &CRYPTO_realloc)
  198.           return realloc_impl(str, num, file, line);
                 ^
  199.   
  200.       FAILTEST();

crypto/mem.c:223:1: return from a call to CRYPTO_realloc
  221.       return realloc(str, num);
  222.   
  223. > }
  224.   
  225.   void *CRYPTO_clear_realloc(void *str, size_t old_len, size_t num,

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

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

crypto/mem.c:252:1: start of procedure CRYPTO_free()
  250.   }
  251.   
  252. > void CRYPTO_free(void *str, const char *file, int line)
  253.   {
  254.       if (free_impl != NULL && free_impl != &CRYPTO_free) {

crypto/mem.c:254:9: Taking true branch
  252.   void CRYPTO_free(void *str, const char *file, int line)
  253.   {
  254.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                 ^
  255.           free_impl(str, file, line);
  256.           return;

crypto/mem.c:254:30: Taking true branch
  252.   void CRYPTO_free(void *str, const char *file, int line)
  253.   {
  254.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
                                      ^
  255.           free_impl(str, file, line);
  256.           return;

crypto/mem.c:255:9: Skipping __function_pointer__(): unresolved function pointer
  253.   {
  254.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
  255.           free_impl(str, file, line);
                 ^
  256.           return;
  257.       }

crypto/mem.c:256:9: 
  254.       if (free_impl != NULL && free_impl != &CRYPTO_free) {
  255.           free_impl(str, file, line);
  256. >         return;
  257.       }
  258.   

crypto/mem.c:270:1: return from a call to CRYPTO_free
  268.       free(str);
  269.   #endif
  270. > }
  271.   
  272.   void CRYPTO_clear_free(void *str, size_t num, const char *file, int line)

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

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