crypto/ui/ui_util.c:111: error: NULL_DEREFERENCE
  pointer `data` last assigned on line 108 could be null and is dereferenced at line 111, column 23.
Showing all 25 steps of the trace


crypto/ui/ui_util.c:102:1: start of procedure ui_read()
100.       return 1;
101.   }
102. > static int ui_read(UI *ui, UI_STRING *uis)
103.   {
104.       switch (UI_get_string_type(uis)) {

crypto/ui/ui_util.c:104:5: 
102.   static int ui_read(UI *ui, UI_STRING *uis)
103.   {
104. >     switch (UI_get_string_type(uis)) {
105.       case UIT_PROMPT:
106.           {

crypto/ui/ui_lib.c:751:1: start of procedure UI_get_string_type()
  749.   }
  750.   
  751. > enum UI_string_types UI_get_string_type(UI_STRING *uis)
  752.   {
  753.       return uis->type;

crypto/ui/ui_lib.c:753:5: 
  751.   enum UI_string_types UI_get_string_type(UI_STRING *uis)
  752.   {
  753. >     return uis->type;
  754.   }
  755.   

crypto/ui/ui_lib.c:754:1: return from a call to UI_get_string_type
  752.   {
  753.       return uis->type;
  754. > }
  755.   
  756.   int UI_get_input_flags(UI_STRING *uis)

crypto/ui/ui_util.c:105:5: Switch condition is true. Entering switch case
103.   {
104.       switch (UI_get_string_type(uis)) {
105.       case UIT_PROMPT:
           ^
106.           {
107.               char result[PEM_BUFSIZE + 1];

crypto/ui/ui_util.c:108:13: 
106.           {
107.               char result[PEM_BUFSIZE + 1];
108. >             const struct pem_password_cb_data *data =
109.                   UI_method_get_ex_data(UI_get_method(ui), ui_method_data_index);
110.               int maxsize = UI_get_result_maxsize(uis);

crypto/ui/ui_lib.c:567:1: start of procedure UI_get_method()
  565.   }
  566.   
  567. > const UI_METHOD *UI_get_method(UI *ui)
  568.   {
  569.       return ui->meth;

crypto/ui/ui_lib.c:569:5: 
  567.   const UI_METHOD *UI_get_method(UI *ui)
  568.   {
  569. >     return ui->meth;
  570.   }
  571.   

crypto/ui/ui_lib.c:570:1: return from a call to UI_get_method
  568.   {
  569.       return ui->meth;
  570. > }
  571.   
  572.   const UI_METHOD *UI_set_method(UI *ui, const UI_METHOD *meth)

crypto/ui/ui_lib.c:746:1: start of procedure UI_method_get_ex_data()
  744.   }
  745.   
  746. > const void *UI_method_get_ex_data(const UI_METHOD *method, int idx)
  747.   {
  748.       return CRYPTO_get_ex_data(&method->ex_data, idx);

crypto/ui/ui_lib.c:748:5: 
  746.   const void *UI_method_get_ex_data(const UI_METHOD *method, int idx)
  747.   {
  748. >     return CRYPTO_get_ex_data(&method->ex_data, idx);
  749.   }
  750.   

crypto/ex_data.c:394:1: start of procedure CRYPTO_get_ex_data()
    392.    * particular index in the class used by this variable
    393.    */
    394. > void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
    395.   {
    396.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))

crypto/ex_data.c:396:9: Taking true branch
    394.   void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)
    395.   {
    396.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))
                   ^
    397.           return NULL;
    398.       return sk_void_value(ad->sk, idx);

crypto/ex_data.c:397:9: 
    395.   {
    396.       if (ad->sk == NULL || idx >= sk_void_num(ad->sk))
    397. >         return NULL;
    398.       return sk_void_value(ad->sk, idx);
    399.   }

crypto/ex_data.c:399:1: return from a call to CRYPTO_get_ex_data
    397.           return NULL;
    398.       return sk_void_value(ad->sk, idx);
    399. > }

crypto/ui/ui_lib.c:749:1: return from a call to UI_method_get_ex_data
  747.   {
  748.       return CRYPTO_get_ex_data(&method->ex_data, idx);
  749. > }
  750.   
  751.   enum UI_string_types UI_get_string_type(UI_STRING *uis)

crypto/ui/ui_util.c:110:13: 
108.               const struct pem_password_cb_data *data =
109.                   UI_method_get_ex_data(UI_get_method(ui), ui_method_data_index);
110. >             int maxsize = UI_get_result_maxsize(uis);
111.               int len = data->cb(result,
112.                                  maxsize > PEM_BUFSIZE ? PEM_BUFSIZE : maxsize,

crypto/ui/ui_lib.c:826:1: start of procedure UI_get_result_maxsize()
  824.   }
  825.   
  826. > int UI_get_result_maxsize(UI_STRING *uis)
  827.   {
  828.       switch (uis->type) {

crypto/ui/ui_lib.c:828:5: 
  826.   int UI_get_result_maxsize(UI_STRING *uis)
  827.   {
  828. >     switch (uis->type) {
  829.       case UIT_PROMPT:
  830.       case UIT_VERIFY:

crypto/ui/ui_lib.c:829:5: Switch condition is true. Entering switch case
  827.   {
  828.       switch (uis->type) {
  829.       case UIT_PROMPT:
             ^
  830.       case UIT_VERIFY:
  831.           return uis->_.string_data.result_maxsize;

crypto/ui/ui_lib.c:831:9: 
  829.       case UIT_PROMPT:
  830.       case UIT_VERIFY:
  831. >         return uis->_.string_data.result_maxsize;
  832.       case UIT_NONE:
  833.       case UIT_INFO:

crypto/ui/ui_lib.c:839:1: return from a call to UI_get_result_maxsize
  837.       }
  838.       return -1;
  839. > }
  840.   
  841.   int UI_set_result(UI *ui, UI_STRING *uis, const char *result)

crypto/ui/ui_util.c:112:32: Condition is false
110.               int maxsize = UI_get_result_maxsize(uis);
111.               int len = data->cb(result,
112.                                  maxsize > PEM_BUFSIZE ? PEM_BUFSIZE : maxsize,
                                      ^
113.                                  data->rwflag, UI_get0_user_data(ui));
114.   

crypto/ui/ui_util.c:111:13: 
109.                   UI_method_get_ex_data(UI_get_method(ui), ui_method_data_index);
110.               int maxsize = UI_get_result_maxsize(uis);
111. >             int len = data->cb(result,
112.                                  maxsize > PEM_BUFSIZE ? PEM_BUFSIZE : maxsize,
113.                                  data->rwflag, UI_get0_user_data(ui));

static int ui_read(UI *ui, UI_STRING *uis)
{
    switch (UI_get_string_type(uis)) {
    case UIT_PROMPT:
        {
            char result[PEM_BUFSIZE + 1];
            const struct pem_password_cb_data *data =
                UI_method_get_ex_data(UI_get_method(ui), ui_method_data_index);
            int maxsize = UI_get_result_maxsize(uis);
            int len = data->cb(result,
                               maxsize > PEM_BUFSIZE ? PEM_BUFSIZE : maxsize,
                               data->rwflag, UI_get0_user_data(ui));
            if (len >= 0)
                result[len] = '\0';
            if (len <= 0)
                return len;
            if (UI_set_result(ui, uis, result) >= 0)
                return 1;
            return 0;
        }
    case UIT_VERIFY:
    case UIT_NONE:
    case UIT_BOOLEAN:
    case UIT_INFO:
    case UIT_ERROR:
        break;
    }
    return 1;
}
["static int ui_read(UI *ui, UI_STRING *uis)\n{\n    switch (UI_get_string_type(uis)) {\n    case UIT_PROMPT:\n        {\n            char result[PEM_BUFSIZE + 1];\n            const struct pem_password_cb_data *data =\n                UI_method_get_ex_data(UI_get_method(ui), ui_method_data_index);\n            int maxsize = UI_get_result_maxsize(uis);\n            int len = data->cb(result,\n                               maxsize > PEM_BUFSIZE ? PEM_BUFSIZE : maxsize,\n                               data->rwflag, UI_get0_user_data(ui));\n            if (len >= 0)\n                result[len] = '\\0';\n            if (len <= 0)\n                return len;\n            if (UI_set_result(ui, uis, result) >= 0)\n                return 1;\n            return 0;\n        }\n    case UIT_VERIFY:\n    case UIT_NONE:\n    case UIT_BOOLEAN:\n    case UIT_INFO:\n    case UIT_ERROR:\n        break;\n    }\n    return 1;\n}", 'enum UI_string_types UI_get_string_type(UI_STRING *uis)\n{\n    return uis->type;\n}', 'const UI_METHOD *UI_get_method(UI *ui)\n{\n    return ui->meth;\n}', 'const void *UI_method_get_ex_data(const UI_METHOD *method, int idx)\n{\n    return CRYPTO_get_ex_data(&method->ex_data, idx);\n}', 'void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx)\n{\n    if (ad->sk == NULL || idx >= sk_void_num(ad->sk))\n        return NULL;\n    return sk_void_value(ad->sk, idx);\n}', 'int UI_get_result_maxsize(UI_STRING *uis)\n{\n    switch (uis->type) {\n    case UIT_PROMPT:\n    case UIT_VERIFY:\n        return uis->_.string_data.result_maxsize;\n    case UIT_NONE:\n    case UIT_INFO:\n    case UIT_ERROR:\n    case UIT_BOOLEAN:\n        break;\n    }\n    return -1;\n}']