ruby-changes:36944
From: nobu <ko1@a...>
Date: Fri, 26 Dec 2014 15:09:28 +0900 (JST)
Subject: [ruby-changes:36944] nobu:r49025 (trunk): uninitialized variable
nobu 2014-12-26 15:09:11 +0900 (Fri, 26 Dec 2014) New Revision: 49025 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=49025 Log: uninitialized variable * process.c (rb_spawn_process): get rid of usage of uninitialized variable. reported by Denis Denisov <denji0k AT gmail.com>. * regexec.c (match_at): ditto. * ext/win32ole/win32ole.c (ole_wc2mb_alloc, ole_vstr2wc, ole_mb2wc): ditto. Modified files: trunk/ChangeLog trunk/ext/win32ole/win32ole.c trunk/process.c trunk/regexec.c Index: ChangeLog =================================================================== --- ChangeLog (revision 49024) +++ ChangeLog (revision 49025) @@ -1,4 +1,13 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 -Fri Dec 26 14:51:34 2014 Nobuyoshi Nakada <nobu@r...> +Fri Dec 26 15:09:08 2014 Nobuyoshi Nakada <nobu@r...> + + * process.c (rb_spawn_process): get rid of usage of uninitialized + variable. + reported by Denis Denisov <denji0k AT gmail.com>. + + * regexec.c (match_at): ditto. + + * ext/win32ole/win32ole.c (ole_wc2mb_alloc, ole_vstr2wc, ole_mb2wc): + ditto. * dir.c (ruby_glob0): no need to check never-NULL pointer. reported by Denis Denisov <denji0k AT gmail.com>. Index: process.c =================================================================== --- process.c (revision 49024) +++ process.c (revision 49025) @@ -3910,6 +3910,7 @@ rb_spawn_process(struct rb_execarg *earg https://github.com/ruby/ruby/blob/trunk/process.c#L3910 } status = system(StringValuePtr(prog)); rb_last_status_set((status & 0xff) << 8, 0); + pid = 1; /* dummy */ # endif rb_execarg_run_options(&sarg, NULL, errmsg, errmsg_buflen); Index: ext/win32ole/win32ole.c =================================================================== --- ext/win32ole/win32ole.c (revision 49024) +++ ext/win32ole/win32ole.c (revision 49025) @@ -579,11 +579,13 @@ load_conv_function51932(void) https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L579 pIMultiLanguage = p; } } +#define need_conv_function51932() (load_conv_function51932(), 1) #else #define load_conv_function51932() failed_load_conv51932() +#define need_conv_function51932() (failed_load_conv51932(), 0) #endif -#define conv_51932(cp) ((cp) == 51932 && (load_conv_function51932(), 1)) +#define conv_51932(cp) ((cp) == 51932 && need_conv_function51932()) static void set_ole_codepage(UINT cp) @@ -711,8 +713,8 @@ ole_wc2mb_alloc(LPWSTR pw, char *(alloc) https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L713 ole_raise(hr, eWIN32OLERuntimeError, "fail to convert Unicode to CP%d", cWIN32OLE_cp); } pm[size] = '\0'; + return pm; #endif - return pm; } size = WideCharToMultiByte(cWIN32OLE_cp, 0, pw, -1, NULL, 0, NULL, NULL); if (size) { @@ -893,8 +895,8 @@ ole_vstr2wc(VALUE vstr) https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L895 if (FAILED(hr)) { ole_raise(hr, eWIN32OLERuntimeError, "fail to convert CP%d to Unicode", cp); } -#endif return pw; +#endif } size = MultiByteToWideChar(cp, 0, RSTRING_PTR(vstr), RSTRING_LEN(vstr), NULL, 0); pw = SysAllocStringLen(NULL, size); @@ -923,8 +925,8 @@ ole_mb2wc(char *pm, int len) https://github.com/ruby/ruby/blob/trunk/ext/win32ole/win32ole.c#L925 if (FAILED(hr)) { ole_raise(hr, eWIN32OLERuntimeError, "fail to convert CP%d to Unicode", cWIN32OLE_cp); } -#endif return pw; +#endif } size = MultiByteToWideChar(cWIN32OLE_cp, 0, pm, len, NULL, 0); pw = SysAllocStringLen(NULL, size - 1); Index: regexec.c =================================================================== --- regexec.c (revision 49024) +++ regexec.c (revision 49025) @@ -1408,8 +1408,9 @@ match_at(regex_t* reg, const UChar* str, https://github.com/ruby/ruby/blob/trunk/regexec.c#L1408 int len; fprintf(stderr, "%4"PRIdPTR"> \"", (*p == OP_FINISH) ? (ptrdiff_t )-1 : s - str); bp = buf; + q = s; if (*p != OP_FINISH) { /* s may not be a valid pointer if OP_FINISH. */ - for (i = 0, q = s; i < 7 && q < end; i++) { + for (i = 0; i < 7 && q < end; i++) { len = enclen(encode, q, end); while (len-- > 0) *bp++ = *q++; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/