From be2ec4a06948ede278a4625e5c02aa06f40d4e2b Mon Sep 17 00:00:00 2001 From: AADARSHPUROHIT466 Date: Thu, 19 Feb 2026 22:56:34 +0530 Subject: [PATCH] liboctave: Fix memory allocation check in octave_sort::MergeState::getmemi * liboctave/util/oct-sort.cc (octave_sort::MergeState::getmemi): Check both m_a and m_ia before returning early. The original code only checked m_ia and m_alloced, which could lead to undefined behavior if m_a was not allocated. --- liboctave/util/oct-sort.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/liboctave/util/oct-sort.cc b/liboctave/util/oct-sort.cc index 3ebe936653..bb520d87d4 100644 --- a/liboctave/util/oct-sort.cc +++ b/liboctave/util/oct-sort.cc @@ -563,7 +563,7 @@ template void octave_sort::MergeState::getmemi (octave_idx_type need) { - if (m_ia && need <= m_alloced) + if (m_a && m_ia && need <= m_alloced) return; need = roundupsize (need);