libmp: fix #5: mptole takes `p` xor `pp`

According to http://man.cat-v.org/9front/2/mp mptole either take p or pp:

> Mptobe and mptole convert an mpint to a byte array.  The
> former creates a big endian representation, the latter a
> little endian one.  If the destination buf is not nil, it
> specifies the buffer of length blen for the result.  If the
> representation is less than blen bytes, the rest of the
> buffer is zero filled.  **If buf is nil**, then a buffer is
> allocated and a pointer to it is deposited in the location
> pointed to by **bufp**. Sign is ignored in these conversions,
> i.e., the byte array version is always positive.

Assert accordingly.
This commit is contained in:
Giacomo Tesio 2017-01-18 01:47:28 +01:00
parent 90fe80e73b
commit 0f82a2c3c3
1 changed files with 1 additions and 0 deletions

View File

@ -10,6 +10,7 @@ mptole(mpint *b, uint8_t *p, uint32_t n, uint8_t **pp)
{
int m;
assert((p == nil) != (pp == nil))
m = (mpsignif(b)+7)/8;
if(m == 0)
m++;