crypto/ui/ui_lib.c:256: error: MEMORY_LEAK
  memory dynamically allocated by call to `CRYPTO_strdup()` at line 249, column 23 is not reachable after line 256, column 5.
Showing all 30 steps of the trace


crypto/ui/ui_lib.c:243:1: start of procedure UI_dup_input_string()
241.   
242.   /* Same as UI_add_input_string(), excepts it takes a copy of the prompt */
243. > int UI_dup_input_string(UI *ui, const char *prompt, int flags,
244.                           char *result_buf, int minsize, int maxsize)
245.   {

crypto/ui/ui_lib.c:246:5: 
244.                           char *result_buf, int minsize, int maxsize)
245.   {
246. >     char *prompt_copy = NULL;
247.   
248.       if (prompt) {

crypto/ui/ui_lib.c:248:9: Taking true branch
246.       char *prompt_copy = NULL;
247.   
248.       if (prompt) {
               ^
249.           prompt_copy = OPENSSL_strdup(prompt);
250.           if (prompt_copy == NULL) {

crypto/ui/ui_lib.c:249:9: 
247.   
248.       if (prompt) {
249. >         prompt_copy = OPENSSL_strdup(prompt);
250.           if (prompt_copy == NULL) {
251.               UIerr(UI_F_UI_DUP_INPUT_STRING, ERR_R_MALLOC_FAILURE);

crypto/o_str.c:120:1: start of procedure CRYPTO_strdup()
  118.   }
  119.   
  120. > char *CRYPTO_strdup(const char *str, const char* file, int line)
  121.   {
  122.       char *ret;

crypto/o_str.c:125:9: Taking false branch
  123.       size_t size;
  124.   
  125.       if (str == NULL)
                 ^
  126.           return NULL;
  127.       size = strlen(str) + 1;

crypto/o_str.c:127:5: 
  125.       if (str == NULL)
  126.           return NULL;
  127. >     size = strlen(str) + 1;
  128.       ret = CRYPTO_malloc(size, file, line);
  129.       if (ret != NULL)

crypto/o_str.c:128:5: 
  126.           return NULL;
  127.       size = strlen(str) + 1;
  128. >     ret = CRYPTO_malloc(size, file, line);
  129.       if (ret != NULL)
  130.           memcpy(ret, str, size);

crypto/mem.c:119:1: start of procedure CRYPTO_malloc()
    117.   }
    118.   
    119. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    120.   {
    121.       void *ret = NULL;

crypto/mem.c:121:5: 
    119.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    120.   {
    121. >     void *ret = NULL;
    122.   
    123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)

crypto/mem.c:123:9: Taking false branch
    121.       void *ret = NULL;
    122.   
    123.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                   ^
    124.           return malloc_impl(num, file, line);
    125.   

crypto/mem.c:126:9: Taking false branch
    124.           return malloc_impl(num, file, line);
    125.   
    126.       if (num <= 0)
                   ^
    127.           return NULL;
    128.   

crypto/mem.c:129:5: 
    127.           return NULL;
    128.   
    129. >     allow_customize = 0;
    130.   #ifndef OPENSSL_NO_CRYPTO_MDEBUG
    131.       if (call_malloc_debug) {

crypto/mem.c:139:5: 
    137.       }
    138.   #else
    139. >     osslargused(file); osslargused(line);
    140.       ret = malloc(num);
    141.   #endif

crypto/mem.c:139:24: 
    137.       }
    138.   #else
    139. >     osslargused(file); osslargused(line);
    140.       ret = malloc(num);
    141.   #endif

crypto/mem.c:140:5: 
    138.   #else
    139.       osslargused(file); osslargused(line);
    140. >     ret = malloc(num);
    141.   #endif
    142.   

crypto/mem.c:143:5: 
    141.   #endif
    142.   
    143. >     return ret;
    144.   }
    145.   

crypto/mem.c:144:1: return from a call to CRYPTO_malloc
    142.   
    143.       return ret;
    144. > }
    145.   
    146.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/o_str.c:129:9: Taking true branch
  127.       size = strlen(str) + 1;
  128.       ret = CRYPTO_malloc(size, file, line);
  129.       if (ret != NULL)
                 ^
  130.           memcpy(ret, str, size);
  131.       return ret;

crypto/o_str.c:130:9: 
  128.       ret = CRYPTO_malloc(size, file, line);
  129.       if (ret != NULL)
  130. >         memcpy(ret, str, size);
  131.       return ret;
  132.   }

crypto/o_str.c:131:5: 
  129.       if (ret != NULL)
  130.           memcpy(ret, str, size);
  131. >     return ret;
  132.   }
  133.   

crypto/o_str.c:132:1: return from a call to CRYPTO_strdup
  130.           memcpy(ret, str, size);
  131.       return ret;
  132. > }
  133.   
  134.   char *CRYPTO_strndup(const char *str, size_t s, const char* file, int line)

crypto/ui/ui_lib.c:250:13: Taking false branch
248.       if (prompt) {
249.           prompt_copy = OPENSSL_strdup(prompt);
250.           if (prompt_copy == NULL) {
                   ^
251.               UIerr(UI_F_UI_DUP_INPUT_STRING, ERR_R_MALLOC_FAILURE);
252.               return 0;

crypto/ui/ui_lib.c:256:5: 
254.       }
255.   
256. >     return general_allocate_string(ui, prompt_copy, 1,
257.                                      UIT_PROMPT, flags, result_buf, minsize,
258.                                      maxsize, NULL);

crypto/ui/ui_lib.c:159:1: start of procedure general_allocate_string()
  157.   }
  158.   
  159. > static int general_allocate_string(UI *ui, const char *prompt,
  160.                                      int prompt_freeable,
  161.                                      enum UI_string_types type, int input_flags,

crypto/ui/ui_lib.c:165:5: 
  163.                                      const char *test_buf)
  164.   {
  165. >     int ret = -1;
  166.       UI_STRING *s = general_allocate_prompt(ui, prompt, prompt_freeable,
  167.                                              type, input_flags, result_buf);

crypto/ui/ui_lib.c:166:5: Skipping general_allocate_prompt(): empty list of specs
  164.   {
  165.       int ret = -1;
  166.       UI_STRING *s = general_allocate_prompt(ui, prompt, prompt_freeable,
             ^
  167.                                              type, input_flags, result_buf);
  168.   

crypto/ui/ui_lib.c:169:9: Taking false branch
  167.                                              type, input_flags, result_buf);
  168.   
  169.       if (s) {
                 ^
  170.           if (allocate_string_stack(ui) >= 0) {
  171.               s->_.string_data.result_minsize = minsize;

crypto/ui/ui_lib.c:181:5: 
  179.               free_string(s);
  180.       }
  181. >     return ret;
  182.   }
  183.   

crypto/ui/ui_lib.c:182:1: return from a call to general_allocate_string
  180.       }
  181.       return ret;
  182. > }
  183.   
  184.   static int general_allocate_boolean(UI *ui,

int UI_dup_input_string(UI *ui, const char *prompt, int flags,
                        char *result_buf, int minsize, int maxsize)
{
    char *prompt_copy = NULL;
    if (prompt) {
        prompt_copy = OPENSSL_strdup(prompt);
        if (prompt_copy == NULL) {
            UIerr(UI_F_UI_DUP_INPUT_STRING, ERR_R_MALLOC_FAILURE);
            return 0;
        }
    }
    return general_allocate_string(ui, prompt_copy, 1,
                                   UIT_PROMPT, flags, result_buf, minsize,
                                   maxsize, NULL);
}
['int UI_dup_input_string(UI *ui, const char *prompt, int flags,\n                        char *result_buf, int minsize, int maxsize)\n{\n    char *prompt_copy = NULL;\n    if (prompt) {\n        prompt_copy = OPENSSL_strdup(prompt);\n        if (prompt_copy == NULL) {\n            UIerr(UI_F_UI_DUP_INPUT_STRING, ERR_R_MALLOC_FAILURE);\n            return 0;\n        }\n    }\n    return general_allocate_string(ui, prompt_copy, 1,\n                                   UIT_PROMPT, flags, result_buf, minsize,\n                                   maxsize, NULL);\n}', 'char *CRYPTO_strdup(const char *str, const char* file, int line)\n{\n    char *ret;\n    size_t size;\n    if (str == NULL)\n        return NULL;\n    size = strlen(str) + 1;\n    ret = CRYPTO_malloc(size, file, line);\n    if (ret != NULL)\n        memcpy(ret, str, size);\n    return ret;\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    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}', 'static int general_allocate_string(UI *ui, const char *prompt,\n                                   int prompt_freeable,\n                                   enum UI_string_types type, int input_flags,\n                                   char *result_buf, int minsize, int maxsize,\n                                   const char *test_buf)\n{\n    int ret = -1;\n    UI_STRING *s = general_allocate_prompt(ui, prompt, prompt_freeable,\n                                           type, input_flags, result_buf);\n    if (s) {\n        if (allocate_string_stack(ui) >= 0) {\n            s->_.string_data.result_minsize = minsize;\n            s->_.string_data.result_maxsize = maxsize;\n            s->_.string_data.test_buf = test_buf;\n            ret = sk_UI_STRING_push(ui->strings, s);\n            if (ret <= 0)\n                ret--;\n        } else\n            free_string(s);\n    }\n    return ret;\n}']