[ruby-oci8-commit] [573] trunk/ruby-oci8: Fix segmentation fault when metadata are accessed after the session is disconnected .

nobody at rubyforge.org nobody at rubyforge.org
Tue Jul 30 06:37:18 UTC 2013


Revision: 573
Author:   kubo
Date:     2013-07-30 06:37:17 +0000 (Tue, 30 Jul 2013)
Log Message:
-----------
Fix segmentation fault when metadata are accessed after the session is disconnected.

Modified Paths:
--------------
    trunk/ruby-oci8/ChangeLog
    trunk/ruby-oci8/ext/oci8/metadata.c
    trunk/ruby-oci8/ext/oci8/ocihandle.c
    trunk/ruby-oci8/test/test_metadata.rb

Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog	2013-07-24 14:55:52 UTC (rev 572)
+++ trunk/ruby-oci8/ChangeLog	2013-07-30 06:37:17 UTC (rev 573)
@@ -1,3 +1,8 @@
+2013-07-30  KUBO Takehiro  <kubo at jiubao.org>
+	* ext/oci8/metadata.c, ext/oci8/ocihandle.c, test/test_metadata.rb:
+	    Fix segmentation fault when metadata are accessed after the
+	    session is disconnected.
+
 2013-07-24  KUBO Takehiro  <kubo at jiubao.org>
 	* lib/oci8/metadata.rb, test/test_package_type.rb:
 	    Add OCI8::Metadata::Type#package_name and

Modified: trunk/ruby-oci8/ext/oci8/metadata.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/metadata.c	2013-07-24 14:55:52 UTC (rev 572)
+++ trunk/ruby-oci8/ext/oci8/metadata.c	2013-07-30 06:37:17 UTC (rev 573)
@@ -154,6 +154,7 @@
     chker2(OCIDescribeAny_nb(svcctx, svcctx->base.hp.svc, oci8_errhp, objptr, objlen,
                              objtype, OCI_DEFAULT, (ub1)FIX2INT(type), desc->hp.dschp),
            &svcctx->base);
+    oci8_link_to_parent(desc, &svcctx->base);
     chker2(OCIAttrGet(desc->hp.dschp, OCI_HTYPE_DESCRIBE, &parmhp, 0, OCI_ATTR_PARAM, oci8_errhp),
            &svcctx->base);
     return oci8_metadata_create(parmhp, self, obj);

Modified: trunk/ruby-oci8/ext/oci8/ocihandle.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/ocihandle.c	2013-07-24 14:55:52 UTC (rev 572)
+++ trunk/ruby-oci8/ext/oci8/ocihandle.c	2013-07-30 06:37:17 UTC (rev 573)
@@ -140,6 +140,10 @@
     ub4 size = 0;
     sword rv;
 
+    if (base->type == 0) {
+        return Qnil;
+    }
+
     v.ub8val = MAGIC_NUMBER;
     rb_scan_args(argc, argv, "11", &attr_type, &strict);
     if (argc == 1) {

Modified: trunk/ruby-oci8/test/test_metadata.rb
===================================================================
--- trunk/ruby-oci8/test/test_metadata.rb	2013-07-24 14:55:52 UTC (rev 572)
+++ trunk/ruby-oci8/test/test_metadata.rb	2013-07-30 06:37:17 UTC (rev 573)
@@ -8,7 +8,7 @@
   end
 
   def teardown
-    @conn.logoff
+    @conn.logoff if @conn
   end
 
   def drop_type(name, drop_body = false)
@@ -1526,4 +1526,11 @@
 
   end
 
+  def test_access_metadata_after_logoff
+    metadata = @conn.describe_any('MDSYS.SDO_GEOMETRY')
+    @conn.logoff
+    @conn = nil
+    metadata.inspect # This should not cause segmentation fault.
+  end
+
 end # TestMetadata



More information about the ruby-oci8-commit mailing list