utf8_helper.cpp
changeset 37 863fc3ccd19d
parent 10 15fd256d4adb
child 38 d314ed57180c
     1.1 --- a/utf8_helper.cpp	Sun May 31 13:30:25 2015 +0200
     1.2 +++ b/utf8_helper.cpp	Sun May 31 17:03:40 2015 +0200
     1.3 @@ -46,6 +46,9 @@
     1.4  
     1.5          string utf8_string(BSTR bstr, NORM_FORM norm)
     1.6          {
     1.7 +            if (bstr == NULL)
     1.8 +                return "";
     1.9 +
    1.10              return utf8_string((wstring) (wchar_t *) _bstr_t(bstr, true), norm);
    1.11          }
    1.12  
    1.13 @@ -77,6 +80,9 @@
    1.14  
    1.15          CComSafeArray<BSTR> string_array(const ::stringlist_t *stringlist)
    1.16          {
    1.17 +            if (stringlist == NULL)
    1.18 +                return CComSafeArray<BSTR>((ULONG)0);
    1.19 +
    1.20              CComSafeArray<BSTR> sa_string_list;
    1.21              int n = 0;
    1.22              for (const ::stringlist_t *k = stringlist; k != NULL; k = k->next) {
    1.23 @@ -94,6 +100,9 @@
    1.24  
    1.25          ::stringlist_t * new_stringlist(const SAFEARRAY * safearray)
    1.26          {
    1.27 +            if (safearray == NULL)
    1.28 +                return NULL;
    1.29 +
    1.30              CComSafeArray<BSTR> sa(safearray);
    1.31              int n_strings = 0;
    1.32              ::stringlist_t *_stringlist = ::new_stringlist((const char *) NULL);