Fix crash when using --trace 10 or above
uint8_t is typedef'd to char, thus boost::lexical_cast treats it as such instead of a number.
This commit is contained in:
parent
5b42031ec1
commit
f1478851ee
4 changed files with 18 additions and 3 deletions
|
|
@ -514,7 +514,7 @@ void handle_debug_options(int argc, char * argv[])
|
|||
#if TRACING_ON
|
||||
_log_level = LOG_TRACE;
|
||||
try {
|
||||
_trace_level = boost::lexical_cast<uint8_t>(argv[i + 1]);
|
||||
_trace_level = boost::lexical_cast<uint16_t>(argv[i + 1]);
|
||||
}
|
||||
catch (const boost::bad_lexical_cast&) {
|
||||
throw std::logic_error(_("Argument to --trace must be an integer"));
|
||||
|
|
|
|||
|
|
@ -574,7 +574,7 @@ std::ostream * _log_stream = &std::cerr;
|
|||
std::ostringstream _log_buffer;
|
||||
|
||||
#if TRACING_ON
|
||||
uint8_t _trace_level;
|
||||
uint16_t _trace_level;
|
||||
#endif
|
||||
|
||||
static bool logger_has_run = false;
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ void logger_func(log_level_t level);
|
|||
|
||||
#if TRACING_ON
|
||||
|
||||
extern uint8_t _trace_level;
|
||||
extern uint16_t _trace_level;
|
||||
|
||||
#define SHOW_TRACE(lvl) \
|
||||
(ledger::_log_level >= ledger::LOG_TRACE && lvl <= ledger::_trace_level)
|
||||
|
|
|
|||
15
test/baseline/opt-trace.test
Normal file
15
test/baseline/opt-trace.test
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
2007/02/02 RD VMMXX
|
||||
Assets:Investments:Vanguard:VMMXX 0.350 VMMXX @ $1.00
|
||||
Income:Dividends:Vanguard:VMMXX $-0.35
|
||||
|
||||
; Using values with two or more digits as the argument to the --trace option
|
||||
; resulted in a segmentation fault.
|
||||
; Since ledger prints debugging information to stderr when the --trace option
|
||||
; was given and that debugging information contains timing information, e.g. [1ms]
|
||||
; which is likely to differ on each test run, this test only checks that ledger
|
||||
; does not crash when the --trace options was specified.
|
||||
test reg --trace 10 2>/dev/null
|
||||
07-Feb-02 RD VMMXX As:Inves:Vanguar:VMMXX 0.350 VMMXX 0.350 VMMXX
|
||||
In:Divid:Vanguar:VMMXX $-0.35 $-0.35
|
||||
0.350 VMMXX
|
||||
end test
|
||||
Loading…
Add table
Reference in a new issue