summaryrefslogtreecommitdiff
path: root/ext/dl/handle.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-11 04:03:14 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-11 04:03:14 +0000
commit7e59a8c5e4dcbc19170a54e8a26f77e7256ee29d (patch)
tree42b25b0ddabfa86c21b63bd5959acc9939fded20 /ext/dl/handle.c
parent745bc1fd83595c869e9d4b3e5e933e332a6c7c8d (diff)
* ext/dl/handle.c (rb_dlhandle_sym): fixed heap corruption.
[ruby-core:22822] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22883 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/dl/handle.c')
-rw-r--r--ext/dl/handle.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/ext/dl/handle.c b/ext/dl/handle.c
index 474e97da3d..a65e4ab5cd 100644
--- a/ext/dl/handle.c
+++ b/ext/dl/handle.c
@@ -166,6 +166,7 @@ rb_dlhandle_sym(VALUE self, VALUE sym)
func = dlsym(handle, name);
CHECK_DLERROR;
+#if defined(FUNC_STDCALL)
if( !func ){
int len = strlen(name);
char *name_n;
@@ -173,14 +174,12 @@ rb_dlhandle_sym(VALUE self, VALUE sym)
{
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 @@ rb_dlhandle_sym(VALUE self, VALUE sym)
CHECK_DLERROR;
if( func ) break;
}
- xfree(name_n);
if( func ) goto found;
name_n[len-1] = 'A';
name_n[len++] = '@';
@@ -204,11 +202,13 @@ rb_dlhandle_sym(VALUE self, VALUE sym)
CHECK_DLERROR;
if( func ) break;
}
- if( !func ){
- rb_raise(rb_eDLError, "unknown symbol \"%s\"", name);
- }
+ found:
+ xfree(name_n);
+ }
+#endif
+ if( !func ){
+ rb_raise(rb_eDLError, "unknown symbol \"%s\"", name);
}
- found:
return PTR2NUM(func);
}