ruby-changes:41250
From: suke <ko1@a...>
Date: Sun, 27 Dec 2015 09:48:25 +0900 (JST)
Subject: [ruby-changes:41250] suke:r53322 (trunk): * ext/win32ole/win32ole.c (ole_vstr2wc, ole_variant2val): fix blank
suke 2015-12-27 09:48:20 +0900 (Sun, 27 Dec 2015) New Revision: 53322 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53322 Log: * ext/win32ole/win32ole.c (ole_vstr2wc, ole_variant2val): fix blank string conversion. [Bug #11880] Thanks Akio Tajima for the patch! Modified files: trunk/ChangeLog trunk/ext/win32ole/win32ole.c Index: ChangeLog =================================================================== --- ChangeLog (revision 53321) +++ ChangeLog (revision 53322) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sun Dec 27 09:47:20 2015 Masaki Suketa <masaki.suketa@n...> + + * 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 <yooobuntu@1...> * doc/extension.rdoc: [DOC] `nul` should be uppercase. Index: ext/win32ole/win32ole.c =================================================================== --- ext/win32ole/win32ole.c (revision 53321) +++ ext/win32ole/win32ole.c (revision 53322) @@ -864,6 +864,9 @@ ole_vstr2wc(VALUE vstr) https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L864 /* 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) https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L1574 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; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/