From d857a4d1cbc7c0853a88064536957dd0d225418f Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 26 Feb 2014 10:48:21 -0600 Subject: in DateTime::format(), don't assign NULL to a std::string --- src/date-time.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/date-time.cpp') diff --git a/src/date-time.cpp b/src/date-time.cpp index e6d99cd..432d877 100644 --- a/src/date-time.cpp +++ b/src/date-time.cpp @@ -85,9 +85,15 @@ GDateTime* DateTime::get() const std::string DateTime::format(const std::string& fmt) const { - const auto str = g_date_time_format(get(), fmt.c_str()); - std::string ret = str; - g_free(str); + std::string ret; + + gchar* str = g_date_time_format(get(), fmt.c_str()); + if (str) + { + ret = str; + g_free(str); + } + return ret; } -- cgit v1.2.3