This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] MIPS: Prevent buffer overrun in uninitialised variable fix


On Thu, Apr 20, 2017 at 12:49:49PM +0000, Matthew Fortune wrote:
> Hi Jeff,
> 
> I missed a load of test failures while on vacation and just noticed
> that the fix you did for a potentially uninitialized variable warning
> is overwriting the stack and breaking MSA in MIPS.
> 
> I guess you may have intended to set the length appropriately and
> only zero the elements that would not be set in the loop:
> 
> memset (&orig_perm[nelt], 0, MAX_VECT_LEN - nelt);
> 
> but I switched it to just zero initialise the whole array for
> simplicity in the patch below.
> 
> I thought I'd check with you before committing. Obviously I'd like to
> apply this to GCC 7 branch as well.

As it is just 16, it is not a big deal either way, memsetting everything
might be even faster.  If it would be bigger than that, the MAX_VECT_LEN -
nelt case would be better.

> gcc/
> 	* config/mips/mips.c (mips_expand_vec_perm_const): Re-fix
> 	uninitialized variable warning to avoid buffer overrun.

Ok, thanks, even for GCC 7 branch.

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]