ruby-changes:11272
From: nobu <ko1@a...>
Date: Wed, 11 Mar 2009 13:03:29 +0900 (JST)
Subject: [ruby-changes:11272] Ruby:r22883 (trunk): * ext/dl/handle.c (rb_dlhandle_sym): fixed heap corruption.
nobu 2009-03-11 13:03:14 +0900 (Wed, 11 Mar 2009) New Revision: 22883 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=22883 Log: * ext/dl/handle.c (rb_dlhandle_sym): fixed heap corruption. [ruby-core:22822] Modified files: trunk/ChangeLog trunk/ext/dl/handle.c Index: ChangeLog =================================================================== --- ChangeLog (revision 22882) +++ ChangeLog (revision 22883) @@ -1,3 +1,8 @@ +Wed Mar 11 13:03:12 2009 Nobuyoshi Nakada <nobu@r...> + + * ext/dl/handle.c (rb_dlhandle_sym): fixed heap corruption. + [ruby-core:22822] + Wed Mar 11 06:12:47 2009 Nobuyoshi Nakada <nobu@r...> * ruby.c (ruby_init_loadpath_safe): expands libpath and removes Index: ext/dl/handle.c =================================================================== --- ext/dl/handle.c (revision 22882) +++ ext/dl/handle.c (revision 22883) @@ -166,6 +166,7 @@ func = dlsym(handle, name); CHECK_DLERROR; +#if defined(FUNC_STDCALL) if( !func ){ int len = strlen(name); char *name_n; @@ -173,14 +174,12 @@ { char *name_a = (char*)xmalloc(len+2); strcpy(name_a, name); + name_n = name_a; name_a[len] = 'A'; name_a[len+1] = '\0'; func = dlsym(handle, name_a); CHECK_DLERROR; - if( func ){ - xfree(name_a); - goto found; - } + if( func ) goto found; name_n = xrealloc(name_a, len+6); } #else @@ -194,7 +193,6 @@ CHECK_DLERROR; if( func ) break; } - xfree(name_n); if( func ) goto found; name_n[len-1] = 'A'; name_n[len++] = '@'; @@ -204,11 +202,13 @@ CHECK_DLERROR; if( func ) break; } - if( !func ){ - rb_raise(rb_eDLError, "unknown symbol \"%s\"", name); - } + found: + xfree(name_n); } - found: +#endif + if( !func ){ + rb_raise(rb_eDLError, "unknown symbol \"%s\"", name); + } return PTR2NUM(func); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/