Skip to content

Commit 6b79b4b

Browse files
authored
Merge pull request #43 from nigels-com/formatarg-initialisation
nullptr initialisation of FormatArg pointers, runtime debug mode checks
2 parents 46a6d77 + 48e2e48 commit 6b79b4b

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tinyformat.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,11 @@ namespace detail {
487487
class FormatArg
488488
{
489489
public:
490-
FormatArg() {}
490+
FormatArg()
491+
: m_value(NULL),
492+
m_formatImpl(NULL),
493+
m_toIntImpl(NULL)
494+
{ }
491495

492496
template<typename T>
493497
FormatArg(const T& value)
@@ -499,11 +503,15 @@ class FormatArg
499503
void format(std::ostream& out, const char* fmtBegin,
500504
const char* fmtEnd, int ntrunc) const
501505
{
506+
assert(m_value);
507+
assert(m_formatImpl);
502508
m_formatImpl(out, fmtBegin, fmtEnd, ntrunc, m_value);
503509
}
504510

505511
int toInt() const
506512
{
513+
assert(m_value);
514+
assert(m_toIntImpl);
507515
return m_toIntImpl(m_value);
508516
}
509517

@@ -846,6 +854,7 @@ class FormatList
846854
const FormatList& list);
847855

848856
private:
857+
FormatList();
849858
const detail::FormatArg* m_formatters;
850859
int m_N;
851860
};

0 commit comments

Comments
 (0)