diff options
Diffstat (limited to 'gdb/gmp-utils.c')
-rw-r--r-- | gdb/gmp-utils.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/gdb/gmp-utils.c b/gdb/gmp-utils.c index 0afa344..13fa61d 100644 --- a/gdb/gmp-utils.c +++ b/gdb/gmp-utils.c @@ -69,19 +69,21 @@ void gdb_mpz::export_bits (gdb::array_view<gdb_byte> buf, int endian, bool unsigned_p, bool safe) const { - gdb_assert (buf.size () > 0); - int sign = mpz_sgn (m_val); if (sign == 0) { /* Our value is zero, so no need to call mpz_export to do the work, especially since mpz_export's documentation explicitly says that the function is a noop in this case. Just write zero to - BUF ourselves. */ - memset (buf.data (), 0, buf.size ()); + BUF ourselves, if it is non-empty. In some languages, a + zero-bit type can exist and this is also fine. */ + if (buf.size () > 0) + memset (buf.data (), 0, buf.size ()); return; } + gdb_assert (buf.size () > 0); + if (safe) { /* Determine the maximum range of values that our buffer can |