From 447b846a9bcdae02a550726d31afbf648c1eaafa Mon Sep 17 00:00:00 2001 From: Mike Kestner Date: Wed, 9 Jul 2003 15:40:23 +0000 Subject: check null after conversions. (e_utf8_strftime_fix_am_pm): ditto. fixes 2003-07-09 Mike Kestner * gal/util/e-util.c (e_utf8_strftime): check null after conversions. (e_utf8_strftime_fix_am_pm): ditto. fixes [44904]. svn path=/trunk/; revision=21771 --- e-util/e-util.c | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) (limited to 'e-util') diff --git a/e-util/e-util.c b/e-util/e-util.c index 6f528d57ce..955151dcc5 100644 --- a/e-util/e-util.c +++ b/e-util/e-util.c @@ -771,10 +771,25 @@ size_t e_strftime(char *s, size_t max, const char *fmt, const struct tm *tm) size_t e_utf8_strftime(char *s, size_t max, const char *fmt, const struct tm *tm) { - size_t sz; - char *locale_fmt = g_locale_from_utf8(fmt, -1, NULL, &sz, NULL); - size_t ret = e_strftime(s, max, locale_fmt, tm); - char *buf = g_locale_to_utf8(s, ret, NULL, &sz, NULL); + size_t sz, ret; + char *locale_fmt, *buf; + + locale_fmt = g_locale_from_utf8(fmt, -1, NULL, &sz, NULL); + if (!locale_fmt) + return 0; + + ret = e_strftime(s, max, locale_fmt, tm); + if (!ret) { + g_free (locale_fmt); + return 0; + } + + buf = g_locale_to_utf8(s, ret, NULL, &sz, NULL); + if (!buf) { + g_free (locale_fmt); + return 0; + } + if (sz >= max) { char *tmp = buf + max - 1; tmp = g_utf8_find_prev_char(buf, tmp); @@ -854,10 +869,25 @@ size_t e_strftime_fix_am_pm(char *s, size_t max, const char *fmt, const struct t size_t e_utf8_strftime_fix_am_pm(char *s, size_t max, const char *fmt, const struct tm *tm) { - size_t sz; - char *locale_fmt = g_locale_from_utf8(fmt, -1, NULL, &sz, NULL); - size_t ret = e_strftime_fix_am_pm(s, max, locale_fmt, tm); - char *buf = g_locale_to_utf8(s, ret, NULL, &sz, NULL); + size_t sz, ret; + char *locale_fmt, *buf; + + locale_fmt = g_locale_from_utf8(fmt, -1, NULL, &sz, NULL); + if (!locale_fmt) + return 0; + + ret = e_strftime_fix_am_pm(s, max, locale_fmt, tm); + if (!ret) { + g_free (locale_fmt); + return 0; + } + + buf = g_locale_to_utf8(s, ret, NULL, &sz, NULL); + if (!buf) { + g_free (locale_fmt); + return 0; + } + if (sz >= max) { char *tmp = buf + max - 1; tmp = g_utf8_find_prev_char(buf, tmp); -- cgit /files/lodash.merge-4.6.2'>dependabot/npm_and_yarn/devel/electron4/files/lodash.merge-4.6.2 FreeBSD GNOME current development ports (https://github.com/freebsd/freebsd-ports-gnome)
aboutsummaryrefslogtreecommitdiffstats