From 58fb35672e7001d6a822147de83b688f4de57481 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Perennou Date: Tue, 16 Mar 2021 22:13:51 +0100 Subject: [PATCH] unref the image *after* we used it Otherwise we manipulate potentially deallocated memory. On some distributions things go fine for some reason, but on others the memory actually gets deallocated and garbage is used, leading to a segmentation fault in vips_image_guess_interpretation Signed-off-by: Marc-Antoine Perennou --- vips.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/vips.go b/vips.go index f04d027..43990f3 100644 --- a/vips.go +++ b/vips.go @@ -388,8 +388,9 @@ func vipsInterpretationBuffer(buf []byte) (Interpretation, error) { if err != nil { return InterpretationError, err } + interp := vipsInterpretation(image) C.g_object_unref(C.gpointer(image)) - return vipsInterpretation(image), nil + return interp, nil } func vipsInterpretation(image *C.VipsImage) Interpretation {