This is an automated email from the ASF dual-hosted git repository.

kou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/main by this push:
     new fc9674739e GH-44478: [GLib] Prevent Arrow::ExtensionType.new (#44498)
fc9674739e is described below

commit fc9674739e289da45d1e528f950e14eb24d91b09
Author: Hiroyuki Sato <[email protected]>
AuthorDate: Wed Oct 23 06:44:16 2024 +0900

    GH-44478: [GLib] Prevent Arrow::ExtensionType.new (#44498)
    
    
    
    ### Rationale for this change
    
    This change fixes GH-44478
    
    ### What changes are included in this PR?
    
    This change Prevent `Arrow::ExtensionType.new`. This change fixes 
segmentation fault.
    
    ### Are these changes tested?
    
    YES
    
    Before this change: Cause segmentation fault.
    After this change: raise the exception(TypeError)
    
    ### Are there any user-facing changes?
    
    N/A
    
    Co-Authored-by: Sutou Kouhei <kou@ clear-code.com>
    * GitHub Issue: #44478
    
    Authored-by: Hiroyuki Sato <[email protected]>
    Signed-off-by: Sutou Kouhei <[email protected]>
---
 c_glib/arrow-glib/basic-data-type.cpp   | 6 +++---
 c_glib/test/test-extension-data-type.rb | 6 ++++++
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/c_glib/arrow-glib/basic-data-type.cpp 
b/c_glib/arrow-glib/basic-data-type.cpp
index d1c0600006..dff9725150 100644
--- a/c_glib/arrow-glib/basic-data-type.cpp
+++ b/c_glib/arrow-glib/basic-data-type.cpp
@@ -1660,9 +1660,9 @@ enum {
   PROP_STORAGE_DATA_TYPE = 1
 };
 
-G_DEFINE_TYPE_WITH_PRIVATE(GArrowExtensionDataType,
-                           garrow_extension_data_type,
-                           GARROW_TYPE_DATA_TYPE)
+G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE(GArrowExtensionDataType,
+                                    garrow_extension_data_type,
+                                    GARROW_TYPE_DATA_TYPE)
 
 #define GARROW_EXTENSION_DATA_TYPE_GET_PRIVATE(obj)                            
          \
   static_cast<GArrowExtensionDataTypePrivate *>(                               
          \
diff --git a/c_glib/test/test-extension-data-type.rb 
b/c_glib/test/test-extension-data-type.rb
index 6c114b81e2..8dfee88518 100644
--- a/c_glib/test/test-extension-data-type.rb
+++ b/c_glib/test/test-extension-data-type.rb
@@ -102,4 +102,10 @@ class TestExtensionDataType < Test::Unit::TestCase
                    extension_chunked_array.chunks.collect(&:class),
                  ])
   end
+
+  def test_abstract_class
+    assert_raise(TypeError) do
+      Arrow::ExtensionDataType.new
+    end
+  end
 end

Reply via email to