From d322c59e4e4a7c1d0ff4c811573a33eec439a870 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Mon, 18 Nov 2024 13:23:54 -0800 Subject: [PATCH] Fix one-time memory leak if encoding_list We memoize this result after calculating it, and the amount of memory is tiny, so this shouldn't cause any harm. Still it's good to fix so that tools can find more serious leaks. This was found by compiling ruby with ASAN/LSAN and running: ASAN_OPTIONS="detect_leaks=1" RUBY_FREE_AT_EXIT=1 bundle exec rake --- ext/charlock_holmes/encoding_detector.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/charlock_holmes/encoding_detector.c b/ext/charlock_holmes/encoding_detector.c index 203b110..64127ee 100644 --- a/ext/charlock_holmes/encoding_detector.c +++ b/ext/charlock_holmes/encoding_detector.c @@ -350,6 +350,7 @@ static VALUE rb_get_supported_encodings(VALUE klass) rb_iv_set(klass, "encoding_list", rb_encoding_list); ucsdet_close(csd); + uenum_close(encoding_list); } return rb_encoding_list;