summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlly Betts <olly@survex.com>2010-10-01 04:42:29 +0000
committerOlly Betts <olly@survex.com>2010-10-01 04:42:29 +0000
commiteaada32f264f828ec326f4c91f5c1a73399a8897 (patch)
tree519253ad5fd05ade58417b63d3725249dc595a2f
parent045066e802dd3c56e0e3c6e91fb078ecc75a8d42 (diff)
downloadswig-eaada32f264f828ec326f4c91f5c1a73399a8897.tar.gz
[Ruby] Avoid segfault when a method node has no parentNode (SF#3034054).
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12237 626c5289-ae23-0410-ae9c-e8d60b6d4f22
-rw-r--r--CHANGES.current4
-rw-r--r--Source/Modules/ruby.cxx11
2 files changed, 13 insertions, 2 deletions
diff --git a/CHANGES.current b/CHANGES.current
index c2d2d52f2..d3c8c21d0 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -6,6 +6,10 @@ Version 2.0.1 (in progress)
===========================
2010-10-01: olly
+ [Ruby] Avoid segfault when a method node has no parentNode
+ (SF#3034054).
+
+2010-10-01: olly
[Python] Allow reinitialisation to work with an embedded Python
interpreter (patch from Jim Carroll in SF#3075178).
diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx
index ab1210a79..8461b8bef 100644
--- a/Source/Modules/ruby.cxx
+++ b/Source/Modules/ruby.cxx
@@ -2054,8 +2054,15 @@ public:
// Construct real method name
String* methodName = NewString("");
- if ( isMethod )
- Printv( methodName, Getattr(parentNode(sibl),"sym:name"), ".", NIL );
+ if ( isMethod ) {
+ // Sometimes a method node has no parent (SF#3034054).
+ // This value is used in an exception message, so just skip the class
+ // name in this case so at least we don't segfault. This is probably
+ // just working around a problem elsewhere though.
+ Node *parent_node = parentNode(sibl);
+ if (parent_node)
+ Printv( methodName, Getattr(parent_node,"sym:name"), ".", NIL );
+ }
Append( methodName, Getattr(sibl,"sym:name" ) );
if ( isCtor ) Append( methodName, ".new" );