Jesper Juhl 09c79b6096 mpi: Avoid using freed pointer in mpi_lshift_limbs()
At the start of the function we assign 'a->d' to 'ap'. Then we use the
RESIZE_IF_NEEDED macro on 'a' - this may free 'a->d' and replace it
with newly allocaetd storage. In that case, we'll be operating on
freed memory further down in the function when we index into 'ap[]'.
Since we don't actually need 'ap' until after the use of the
RESIZE_IF_NEEDED macro we can just delay the assignment to it until
after we've potentially resized, thus avoiding the issue.

While I was there anyway I also changed the integer variable 'n' to be
const. It might as well be since we only assign to it once and use it
as a constant, and then the compiler will tell us if we ever assign to
it in the future.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Acked-by: Dmitry Kasatkin <dmitry.kasatkin@intel.com>
Signed-off-by: James Morris <james.l.morris@oracle.com>
2012-04-18 12:14:28 +10:00
..
2011-09-21 13:39:59 -07:00
2005-10-18 08:26:15 -07:00
2011-03-11 14:25:50 +00:00
2008-06-06 11:29:10 -07:00
2011-10-29 21:20:22 +02:00
2007-07-17 10:23:04 -07:00
2006-06-25 10:01:20 -07:00
2012-03-23 16:58:38 -07:00
2006-06-25 10:01:20 -07:00
2007-05-10 18:24:13 +02:00
2011-03-31 11:26:23 -03:00
2012-03-23 16:58:38 -07:00
2012-03-28 15:58:21 -07:00
2012-01-31 23:19:47 +02:00
2011-12-08 19:52:43 -05:00