diff --git a/ChangeLog b/ChangeLog index 0abfa2ac9f..0ceb17d7da 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Sun Dec 27 09:47:20 2015 Masaki Suketa + + * ext/win32ole/win32ole.c (ole_vstr2wc, ole_variant2val): fix blank + string conversion. + [Bug #11880] + Thanks Akio Tajima for the patch! + Sun Dec 27 09:34:53 2015 craft4coder * doc/extension.rdoc: [DOC] `nul` should be uppercase. diff --git a/ext/win32ole/win32ole.c b/ext/win32ole/win32ole.c index 02ad82b4d4..ac3c2a6a73 100644 --- a/ext/win32ole/win32ole.c +++ b/ext/win32ole/win32ole.c @@ -864,6 +864,9 @@ ole_vstr2wc(VALUE vstr) /* do not type-conversion here to prevent from other arguments * changing (if exist) */ Check_Type(vstr, T_STRING); + if (RSTRING_LEN(vstr) == 0) { + return NULL; + } enc = rb_enc_get(vstr); @@ -1571,10 +1574,16 @@ ole_variant2val(VARIANT *pvar) case VT_BSTR: { - if(V_ISBYREF(pvar)) - obj = ole_wc2vstr(*V_BSTRREF(pvar), FALSE); - else - obj = ole_wc2vstr(V_BSTR(pvar), FALSE); + if(V_ISBYREF(pvar)) { + obj = (SysStringLen(*V_BSTRREF(pvar)) == 0) + ? rb_str_new2("") + : ole_wc2vstr(*V_BSTRREF(pvar), FALSE); + } + else { + obj = (SysStringLen(V_BSTR(pvar)) == 0) + ? rb_str_new2("") + : ole_wc2vstr(V_BSTR(pvar), FALSE); + } break; }