From 57a86c7e752da3b4e3ad606ea33e3e89924e35b7 Mon Sep 17 00:00:00 2001 From: Steve Dekorte Date: Fri, 26 Jun 2026 12:01:33 -0700 Subject: [PATCH] Fix incompatible-pointer return in IoFile_readUArrayOfLength_ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC 16 promotes -Wincompatible-pointer-types to an error by default, which broke the native build (discussion #498). IoFile_readUArrayOfLength_ returns UArray *, but its error path returned IONIL(self) — an IoObject *. Besides the type mismatch this was also a latent logic/leak bug: both callers (readBufferOfLength_, readStringOfLength_) test the result for NULL to mean "return Nil", so the non-NULL ioNil pointer made a failed read look successful, and the freshly allocated UArray was leaked. Free the buffer and return NULL, matching the existing end-of-file path. Co-Authored-By: Claude Opus 4.8 --- libs/iovm/source/IoFile.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libs/iovm/source/IoFile.c b/libs/iovm/source/IoFile.c index 8608f721d..631c06e94 100644 --- a/libs/iovm/source/IoFile.c +++ b/libs/iovm/source/IoFile.c @@ -868,7 +868,10 @@ UArray *IoFile_readUArrayOfLength_(IoFile *self, IoObject *locals, size_t length = IoMessage_locals_sizetArgAt_(m, locals, 0); UArray *ba = UArray_new(); IoFile_assertOpen(self, locals, m); - if (IOSTATE->errorRaised) return IONIL(self); + if (IOSTATE->errorRaised) { + UArray_free(ba); + return NULL; + } UArray_readNumberOfItems_fromCStream_(ba, length, DATA(self)->stream);