[ruby-oci8-commit] [373] trunk/ruby-oci8: * ext/oci8/object.c: 1.

nobody at rubyforge.org nobody at rubyforge.org
Sun Dec 6 09:01:39 EST 2009


Revision: 373
Author:   kubo
Date:     2009-12-06 09:01:37 -0500 (Sun, 06 Dec 2009)

Log Message:
-----------
* ext/oci8/object.c: 1. fix segv when GC starts while initializing
    a bind object for object type. (reported by Remi Gagnon)
    2. fix memory leak about 30 bytes per one bind object for object
    type.

Modified Paths:
--------------
    trunk/ruby-oci8/ChangeLog
    trunk/ruby-oci8/ext/oci8/object.c

Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog	2009-11-03 01:55:50 UTC (rev 372)
+++ trunk/ruby-oci8/ChangeLog	2009-12-06 14:01:37 UTC (rev 373)
@@ -1,3 +1,9 @@
+2009-12-06  KUBO Takehiro  <kubo at jiubao.org>
+	* ext/oci8/object.c: 1. fix segv when GC starts while initializing
+	    a bind object for object type. (reported by Remi Gagnon)
+	    2. fix memory leak about 30 bytes per one bind object for object
+	    type.
+
 2009-11-03  KUBO Takehiro  <kubo at jiubao.org>
 	* ext/oci8/object.c: fix segv when binding a collection of string.
 	    (reported by Raimonds Simanovskis)

Modified: trunk/ruby-oci8/ext/oci8/object.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/object.c	2009-11-03 01:55:50 UTC (rev 372)
+++ trunk/ruby-oci8/ext/oci8/object.c	2009-12-06 14:01:37 UTC (rev 373)
@@ -498,11 +498,14 @@
 {
     oci8_bind_t *obind = (oci8_bind_t *)base;
     oci8_hp_obj_t *oho = (oci8_hp_obj_t *)obind->valuep;
-    ub4 idx = 0;
 
-    do {
-        rb_gc_mark(oho[idx].obj);
-    } while (++idx < obind->maxar_sz);
+    if (oho != NULL) {
+        ub4 idx = 0;
+
+        do {
+            rb_gc_mark(oho[idx].obj);
+        } while (++idx < obind->maxar_sz);
+    }
     rb_gc_mark(obind->tdo);
 }
 
@@ -510,14 +513,18 @@
 {
     oci8_bind_t *obind = (oci8_bind_t *)base;
     oci8_hp_obj_t *oho = (oci8_hp_obj_t *)obind->valuep;
-    ub4 idx = 0;
 
-    do {
-        if (oho[idx].hp != NULL) {
-            OCIObjectFree(oci8_envhp, oci8_errhp, oho[idx].hp, OCI_DEFAULT);
-            oho[idx].hp = NULL;
-        }
-    } while (++idx < obind->maxar_sz);
+    if (oho != NULL) {
+        ub4 idx = 0;
+
+        do {
+            if (oho[idx].hp != NULL) {
+                OCIObjectFree(oci8_envhp, oci8_errhp, oho[idx].hp, OCI_DEFAULT);
+                oho[idx].hp = NULL;
+            }
+        } while (++idx < obind->maxar_sz);
+    }
+    oci8_bind_free(base);
 }
 
 static VALUE bind_named_type_get(oci8_bind_t *obind, void *data, void *null_struct)




More information about the ruby-oci8-commit mailing list