From a666fd4e267ffae3d4b21f38d569c61ff56adc9e Mon Sep 17 00:00:00 2001 From: "Field G. Van Zee" Date: Sat, 5 Aug 2017 13:04:31 -0500 Subject: [PATCH] Added edge handling to _determine_blocksize_b(). Details: - Added explicit handling of situations where i == dim to bli_determine_blocksize_b_sub(). This isn't actually needed by any current use case within BLIS, but handling the situation is nonetheless prudent. Thanks to Minh Quan for reporting this issue and requesting the fix. --- frame/base/bli_blksz.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/frame/base/bli_blksz.c b/frame/base/bli_blksz.c index 63fc81711..6d27c52d5 100644 --- a/frame/base/bli_blksz.c +++ b/frame/base/bli_blksz.c @@ -363,6 +363,11 @@ dim_t bli_determine_blocksize_b_sub // chunk that will correspond to the blocksize we are computing now. dim_left_now = dim - i; + // Sanity check: if dim_left_now is zero, then we can return zero + // without going any further. + if ( dim_left_now == 0 ) + return 0; + dim_at_edge = dim_left_now % b_alg; // If dim_left_now is a multiple of b_alg, we can safely return b_alg