From ba2c04072c2f6b1fc50dc8ff3a41098ea6e634e6 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Mon, 27 Sep 2004 18:08:48 -0400 Subject: fixed several segfaults (using new option-scrambler test harness) --- acprep | 4 ++++ amount.cc | 6 ++++-- format.h | 7 ++++--- walk.h | 6 ++++-- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/acprep b/acprep index 1fac5d35..81a4a853 100755 --- a/acprep +++ b/acprep @@ -26,6 +26,10 @@ elif [ "$1" = "--opt" ]; then elif [ "$1" = "--flat-opt" ]; then ./configure CPPFLAGS="$INCDIRS" LDFLAGS="$LIBDIRS" \ CXXFLAGS="-fomit-frame-pointer -fastf -mcpu=7450" --disable-shared +elif [ "$1" = "--safe-opt" ]; then + ./configure CPPFLAGS="$INCDIRS" LDFLAGS="$LIBDIRS" \ + CXXFLAGS="-fomit-frame-pointer -fastf -mcpu=7450 -DDEBUG_LEVEL=1" \ + --disable-shared elif [ "$1" = "--perf" ]; then ./configure CPPFLAGS="$INCDIRS" LDFLAGS="$LIBDIRS" CXXFLAGS="-g -pg" fi diff --git a/amount.cc b/amount.cc index 1a538f40..69ac1738 100644 --- a/amount.cc +++ b/amount.cc @@ -489,9 +489,11 @@ amount_t::operator bool() const if (quantity->prec <= commodity().precision) { return mpz_sgn(MPZ(quantity)) != 0; } else { - assert(commodity_); mpz_set(temp, MPZ(quantity)); - mpz_ui_pow_ui(divisor, 10, quantity->prec - commodity().precision); + if (commodity_) + mpz_ui_pow_ui(divisor, 10, quantity->prec - commodity_->precision); + else + mpz_ui_pow_ui(divisor, 10, quantity->prec); mpz_tdiv_q(temp, temp, divisor); bool zero = mpz_sgn(temp) == 0; return ! zero; diff --git a/format.h b/format.h index f3bf671c..5f6518fd 100644 --- a/format.h +++ b/format.h @@ -115,9 +115,10 @@ class format_entries : public format_transactions void format_last_entry(); virtual void flush() { - format_last_entry(); - last_entry = NULL; - + if (last_entry) { + format_last_entry(); + last_entry = NULL; + } format_transactions::flush(); } virtual void operator()(transaction_t& xact); diff --git a/walk.h b/walk.h index 39a220be..0ac9e133 100644 --- a/walk.h +++ b/walk.h @@ -306,8 +306,10 @@ class changed_value_transactions : public item_handler changed_values_only(_changed_values_only), last_xact(NULL) {} virtual void flush() { - output_diff(std::time(NULL)); - last_xact = NULL; + if (last_xact) { + output_diff(std::time(NULL)); + last_xact = NULL; + } item_handler::flush(); } -- cgit v1.2.3