From 858111ebc4a07bf5e538426456af925a7608eb3b Mon Sep 17 00:00:00 2001 From: Peter Hawkins Date: Wed, 3 Aug 2022 01:01:51 +0000 Subject: [PATCH] Fix out-of-bounds heap access in internals.pyx. If blknos is empty, we unconditionally access blknos[start] where start is 0. This is an out-of-bounds heap access that can be caught by AddressSanitizer, but it's easy to avoid since we are going to ignore the result anyway. --- pandas/_libs/internals.pyx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pandas/_libs/internals.pyx b/pandas/_libs/internals.pyx index be71fe53d35db..159fdbc080fb4 100644 --- a/pandas/_libs/internals.pyx +++ b/pandas/_libs/internals.pyx @@ -469,12 +469,14 @@ def get_blkno_indexers( n = blknos.shape[0] result = list() + + if n == 0: + return result + start = 0 cur_blkno = blknos[start] - if n == 0: - pass - elif group is False: + if group is False: for i in range(1, n): if blknos[i] != cur_blkno: result.append((cur_blkno, slice(start, i)))