summaryrefslogtreecommitdiff
path: root/mpi/mpih-div.c
diff options
context:
space:
mode:
authorXi Wang <xi.wang@gmail.com>2012-08-14 18:54:40 -0400
committerWerner Koch <wk@gnupg.org>2012-08-16 10:48:03 +0200
commit2c54c4da19d3a79e9f749740828026dd41f0521a (patch)
treeacd346d2c038018c59db3697cc07e8fb0d36e073 /mpi/mpih-div.c
parent2196728e2252917849c1be94417258076767021b (diff)
downloadlibgcrypt-2c54c4da19d3a79e9f749740828026dd41f0521a.tar.gz
Replace deliberate division by zero with _gcry_divide_by_zero.
* mpi/mpi-pow.c: Replace 1 / msize. * mpi/mpih-div.c: Replace 1 / dsize. * src/misc.c: Add _gcry_divide_by_zero. -- 1) Division by zero doesn't "provoke a signal" on architectures like PowerPC. 2) C compilers like clang will optimize away these divisions, even though the code tries "to make the compiler not remove" them. This patch redirects these cases to _gcry_divide_by_zero.
Diffstat (limited to 'mpi/mpih-div.c')
-rw-r--r--mpi/mpih-div.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/mpi/mpih-div.c b/mpi/mpih-div.c
index 224b8108..b33dcbfa 100644
--- a/mpi/mpih-div.c
+++ b/mpi/mpih-div.c
@@ -212,9 +212,8 @@ _gcry_mpih_divrem( mpi_ptr_t qp, mpi_size_t qextra_limbs,
switch(dsize) {
case 0:
- /* We are asked to divide by zero, so go ahead and do it! (To make
- the compiler not remove this statement, return the value.) */
- return 1 / dsize;
+ _gcry_divide_by_zero();
+ break;
case 1:
{