Skip to content

Commit 923706f

Browse files
committed
add a null check to matrix_from_array
for safety
1 parent 85c7c5a commit 923706f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/vips/image.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,9 +471,10 @@ def self.new_from_source source, option_string, **opts
471471
def self.matrix_from_array width, height, array
472472
ptr = FFI::MemoryPointer.new :double, array.length
473473
ptr.write_array_of_double array
474-
image = Vips.vips_image_new_matrix_from_array width, height,
474+
img_ptr = Vips.vips_image_new_matrix_from_array width, height,
475475
ptr, array.length
476-
Vips::Image.new image
476+
raise Vips::Error if img_ptr.null?
477+
Vips::Image.new img_ptr
477478
end
478479

479480
# Create a new Image from a 1D or 2D array. A 1D array becomes an

0 commit comments

Comments
 (0)