From 26ce518d4605db37083404615268b2341340ecb4 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Sun, 29 Apr 2018 14:34:33 +0200 Subject: [PATCH] Avoid out of bounds reads from blas_quick_divide_table on big systems Should fix #1541 --- common_x86_64.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common_x86_64.h b/common_x86_64.h index bee88d3ce..0542653a1 100644 --- a/common_x86_64.h +++ b/common_x86_64.h @@ -195,7 +195,9 @@ static __inline int blas_quickdivide(unsigned int x, unsigned int y){ unsigned int result; if (y <= 1) return x; - + + if (y > 64) return x/y; + y = blas_quick_divide_table[y]; __asm__ __volatile__ ("mull %0" :"=d" (result) :"a"(x), "0" (y));