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


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

crypto/ui/ui_lib.c:206:5: 
204.                           char *result_buf, int minsize, int maxsize)
205.   {
206. >     char *prompt_copy = NULL;
207.   
208.       if (prompt != NULL) {

crypto/ui/ui_lib.c:208:9: Taking true branch
206.       char *prompt_copy = NULL;
207.   
208.       if (prompt != NULL) {
               ^
209.           prompt_copy = OPENSSL_strdup(prompt);
210.           if (prompt_copy == NULL) {

crypto/ui/ui_lib.c:209:9: 
207.   
208.       if (prompt != NULL) {
209. >         prompt_copy = OPENSSL_strdup(prompt);
210.           if (prompt_copy == NULL) {
211.               UIerr(UI_F_UI_DUP_INPUT_STRING, ERR_R_MALLOC_FAILURE);

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

crypto/o_str.c:33:9: Taking false branch
  31.       size_t size;
  32.   
  33.       if (str == NULL)
                ^
  34.           return NULL;
  35.       size = strlen(str) + 1;

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

crypto/o_str.c:36:5: 
  34.           return NULL;
  35.       size = strlen(str) + 1;
  36. >     ret = CRYPTO_malloc(size, file, line);
  37.       if (ret != NULL)
  38.           memcpy(ret, str, size);

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

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

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

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

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

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

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

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

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

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

crypto/o_str.c:37:9: Taking true branch
  35.       size = strlen(str) + 1;
  36.       ret = CRYPTO_malloc(size, file, line);
  37.       if (ret != NULL)
                ^
  38.           memcpy(ret, str, size);
  39.       return ret;

crypto/o_str.c:38:9: 
  36.       ret = CRYPTO_malloc(size, file, line);
  37.       if (ret != NULL)
  38. >         memcpy(ret, str, size);
  39.       return ret;
  40.   }

crypto/o_str.c:39:5: 
  37.       if (ret != NULL)
  38.           memcpy(ret, str, size);
  39. >     return ret;
  40.   }
  41.   

crypto/o_str.c:40:1: return from a call to CRYPTO_strdup
  38.           memcpy(ret, str, size);
  39.       return ret;
  40. > }
  41.   
  42.   char *CRYPTO_strndup(const char *str, size_t s, const char* file, int line)

crypto/ui/ui_lib.c:210:13: Taking false branch
208.       if (prompt != NULL) {
209.           prompt_copy = OPENSSL_strdup(prompt);
210.           if (prompt_copy == NULL) {
                   ^
211.               UIerr(UI_F_UI_DUP_INPUT_STRING, ERR_R_MALLOC_FAILURE);
212.               return 0;

crypto/ui/ui_lib.c:216:5: 
214.       }
215.   
216. >     return general_allocate_string(ui, prompt_copy, 1,
217.                                      UIT_PROMPT, flags, result_buf, minsize,
218.                                      maxsize, NULL);

crypto/ui/ui_lib.c:115:1: start of procedure general_allocate_string()
  113.   }
  114.   
  115. > static int general_allocate_string(UI *ui, const char *prompt,
  116.                                      int prompt_freeable,
  117.                                      enum UI_string_types type, int input_flags,

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

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

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

crypto/ui/ui_lib.c:139:5: 
  137.               free_string(s);
  138.       }
  139. >     return ret;
  140.   }
  141.   

crypto/ui/ui_lib.c:140:1: return from a call to general_allocate_string
  138.       }
  139.       return ret;
  140. > }
  141.   
  142.   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    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    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}', '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}']