From 7a31bf07493d365f5b44581dc4aaf3c9d48179f0 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sun, 3 Jan 2016 11:35:43 +1100 Subject: bignum: bugfix: unm shouldn't modify it's operands --- src/openssl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/openssl.c b/src/openssl.c index e146098..a73917a 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -1924,8 +1924,9 @@ static int bn__shr(lua_State *L) { static int bn__unm(lua_State *L) { BIGNUM *a = checksimple(L, 1, BIGNUM_CLASS); + BIGNUM *r = bn_dup(L, a); - BN_set_negative(a, !BN_is_negative(a)); + BN_set_negative(r, !BN_is_negative(a)); return 1; } /* bn__unm() */ -- cgit v1.2.3-59-g8ed1b