aboutsummaryrefslogtreecommitdiffstats
path: root/mpi/mpicoder.c
diff options
context:
space:
mode:
Diffstat (limited to 'mpi/mpicoder.c')
-rw-r--r--mpi/mpicoder.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/mpi/mpicoder.c b/mpi/mpicoder.c
index f796888c8..b05a6f92a 100644
--- a/mpi/mpicoder.c
+++ b/mpi/mpicoder.c
@@ -332,10 +332,13 @@ do_get_buffer( MPI a, unsigned *nbytes, int *sign, int force_secure )
byte *p, *buffer;
mpi_limb_t alimb;
int i;
+ unsigned int n;
if( sign )
*sign = a->sign;
- *nbytes = a->nlimbs * BYTES_PER_MPI_LIMB;
+ *nbytes = n = a->nlimbs * BYTES_PER_MPI_LIMB;
+ if (!n)
+ n++; /* avoid zero length allocation */
p = buffer = force_secure || mpi_is_secure(a) ? m_alloc_secure( *nbytes)
: m_alloc( *nbytes );