summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Kanis <lars@greiz-reinsdorf.de>2023-01-13 13:48:46 +0100
committerGitHub <noreply@github.com>2023-01-13 13:48:46 +0100
commit227d1ce472ec90144249f8cf85b52d85cbab925c (patch)
treeb67eda85cf204a9f92b1597978ec31c81470c1e0
parentcf48b1497ea5e938d8ac261314e4ec6af67f9985 (diff)
parente0b4532635c5ae04a51678bf81a0509b6e901cb3 (diff)
downloadffi-227d1ce472ec90144249f8cf85b52d85cbab925c.tar.gz
Merge pull request #987 from larskanis/raise-before-super
Check the pointer in AutoPointer before super
-rw-r--r--lib/ffi/autopointer.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/ffi/autopointer.rb b/lib/ffi/autopointer.rb
index 679d7e6..6c6333c 100644
--- a/lib/ffi/autopointer.rb
+++ b/lib/ffi/autopointer.rb
@@ -76,9 +76,9 @@ module FFI
# going to be useful if you subclass {AutoPointer}, and override
# #release, which by default does nothing.
def initialize(ptr, proc=nil, &block)
+ raise TypeError, "Invalid pointer" if ptr.nil? || !ptr.kind_of?(Pointer) ||
+ ptr.kind_of?(MemoryPointer) || ptr.kind_of?(AutoPointer)
super(ptr.type_size, ptr)
- raise TypeError, "Invalid pointer" if ptr.nil? || !ptr.kind_of?(Pointer) \
- || ptr.kind_of?(MemoryPointer) || ptr.kind_of?(AutoPointer)
@releaser = if proc
if not proc.respond_to?(:call)