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


crypto/ui/ui_lib.c:207:1: start of procedure UI_dup_input_string()
205.   
206.   /* Same as UI_add_input_string(), excepts it takes a copy of the prompt */
207. > int UI_dup_input_string(UI *ui, const char *prompt, int flags,
208.                           char *result_buf, int minsize, int maxsize)
209.   {

crypto/ui/ui_lib.c:210:5: 
208.                           char *result_buf, int minsize, int maxsize)
209.   {
210. >     char *prompt_copy = NULL;
211.   
212.       if (prompt != NULL) {

crypto/ui/ui_lib.c:212:9: Taking true branch
210.       char *prompt_copy = NULL;
211.   
212.       if (prompt != NULL) {
               ^
213.           prompt_copy = OPENSSL_strdup(prompt);
214.           if (prompt_copy == NULL) {

crypto/ui/ui_lib.c:213:9: 
211.   
212.       if (prompt != NULL) {
213. >         prompt_copy = OPENSSL_strdup(prompt);
214.           if (prompt_copy == NULL) {
215.               UIerr(UI_F_UI_DUP_INPUT_STRING, ERR_R_MALLOC_FAILURE);

crypto/o_str.c:27:1: start of procedure CRYPTO_strdup()
  25.   }
  26.   
  27. > char *CRYPTO_strdup(const char *str, const char* file, int line)
  28.   {
  29.       char *ret;

crypto/o_str.c:31:9: Taking false branch
  29.       char *ret;
  30.   
  31.       if (str == NULL)
                ^
  32.           return NULL;
  33.       ret = CRYPTO_malloc(strlen(str) + 1, file, line);

crypto/o_str.c:33:5: 
  31.       if (str == NULL)
  32.           return NULL;
  33. >     ret = CRYPTO_malloc(strlen(str) + 1, file, line);
  34.       if (ret != NULL)
  35.           strcpy(ret, str);

crypto/mem.c:192:1: start of procedure CRYPTO_malloc()
    190.   #endif
    191.   
    192. > void *CRYPTO_malloc(size_t num, const char *file, int line)
    193.   {
    194.       void *ret = NULL;

crypto/mem.c:194:5: 
    192.   void *CRYPTO_malloc(size_t num, const char *file, int line)
    193.   {
    194. >     void *ret = NULL;
    195.   
    196.       INCREMENT(malloc_count);

crypto/mem.c:197:9: Taking false branch
    195.   
    196.       INCREMENT(malloc_count);
    197.       if (malloc_impl != NULL && malloc_impl != CRYPTO_malloc)
                   ^
    198.           return malloc_impl(num, file, line);
    199.   

crypto/mem.c:200:9: Taking false branch
    198.           return malloc_impl(num, file, line);
    199.   
    200.       if (num == 0)
                   ^
    201.           return NULL;
    202.   

crypto/mem.c:204:9: Taking true branch
    202.   
    203.       FAILTEST();
    204.       if (allow_customize) {
                   ^
    205.           /*
    206.            * Disallow customization after the first allocation. We only set this

crypto/mem.c:210:9: 
    208.            * allocation.
    209.            */
    210. >         allow_customize = 0;
    211.       }
    212.   #if !defined(OPENSSL_NO_CRYPTO_MDEBUG) && !defined(FIPS_MODE)

crypto/mem.c:221:5: 
    219.       }
    220.   #else
    221. >     (void)(file); (void)(line);
    222.       ret = malloc(num);
    223.   #endif

crypto/mem.c:221:19: 
    219.       }
    220.   #else
    221. >     (void)(file); (void)(line);
    222.       ret = malloc(num);
    223.   #endif

crypto/mem.c:222:5: 
    220.   #else
    221.       (void)(file); (void)(line);
    222. >     ret = malloc(num);
    223.   #endif
    224.   

crypto/mem.c:225:5: 
    223.   #endif
    224.   
    225. >     return ret;
    226.   }
    227.   

crypto/mem.c:226:1: return from a call to CRYPTO_malloc
    224.   
    225.       return ret;
    226. > }
    227.   
    228.   void *CRYPTO_zalloc(size_t num, const char *file, int line)

crypto/o_str.c:34:9: Taking true branch
  32.           return NULL;
  33.       ret = CRYPTO_malloc(strlen(str) + 1, file, line);
  34.       if (ret != NULL)
                ^
  35.           strcpy(ret, str);
  36.       return ret;

crypto/o_str.c:35:9: 
  33.       ret = CRYPTO_malloc(strlen(str) + 1, file, line);
  34.       if (ret != NULL)
  35. >         strcpy(ret, str);
  36.       return ret;
  37.   }

crypto/o_str.c:36:5: 
  34.       if (ret != NULL)
  35.           strcpy(ret, str);
  36. >     return ret;
  37.   }
  38.   

crypto/o_str.c:37:1: return from a call to CRYPTO_strdup
  35.           strcpy(ret, str);
  36.       return ret;
  37. > }
  38.   
  39.   char *CRYPTO_strndup(const char *str, size_t s, const char* file, int line)

crypto/ui/ui_lib.c:214:13: Taking false branch
212.       if (prompt != NULL) {
213.           prompt_copy = OPENSSL_strdup(prompt);
214.           if (prompt_copy == NULL) {
                   ^
215.               UIerr(UI_F_UI_DUP_INPUT_STRING, ERR_R_MALLOC_FAILURE);
216.               return 0;

crypto/ui/ui_lib.c:220:5: 
218.       }
219.   
220. >     return general_allocate_string(ui, prompt_copy, 1,
221.                                      UIT_PROMPT, flags, result_buf, minsize,
222.                                      maxsize, NULL);

crypto/ui/ui_lib.c:119:1: start of procedure general_allocate_string()
  117.   }
  118.   
  119. > static int general_allocate_string(UI *ui, const char *prompt,
  120.                                      int prompt_freeable,
  121.                                      enum UI_string_types type, int input_flags,

crypto/ui/ui_lib.c:125:5: 
  123.                                      const char *test_buf)
  124.   {
  125. >     int ret = -1;
  126.       UI_STRING *s = general_allocate_prompt(ui, prompt, prompt_freeable,
  127.                                              type, input_flags, result_buf);

crypto/ui/ui_lib.c:126:5: Skipping general_allocate_prompt(): empty list of specs
  124.   {
  125.       int ret = -1;
  126.       UI_STRING *s = general_allocate_prompt(ui, prompt, prompt_freeable,
             ^
  127.                                              type, input_flags, result_buf);
  128.   

crypto/ui/ui_lib.c:129:9: Taking false branch
  127.                                              type, input_flags, result_buf);
  128.   
  129.       if (s != NULL) {
                 ^
  130.           if (allocate_string_stack(ui) >= 0) {
  131.               s->_.string_data.result_minsize = minsize;

crypto/ui/ui_lib.c:143:5: 
  141.               free_string(s);
  142.       }
  143. >     return ret;
  144.   }
  145.   

crypto/ui/ui_lib.c:144:1: return from a call to general_allocate_string
  142.       }
  143.       return ret;
  144. > }
  145.   
  146.   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 != NULL) {
        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 != NULL) {\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    if (str == NULL)\n        return NULL;\n    ret = CRYPTO_malloc(strlen(str) + 1, file, line);\n    if (ret != NULL)\n        strcpy(ret, str);\n    return ret;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    INCREMENT(malloc_count);\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    if (allow_customize) {\n        allow_customize = 0;\n    }\n#if !defined(OPENSSL_NO_CRYPTO_MDEBUG) && !defined(FIPS_MODE)\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    (void)(file); (void)(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 != NULL) {\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                free_string(s);\n            }\n        } else\n            free_string(s);\n    }\n    return ret;\n}']