aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorMike Kestner <mkestner@ximian.com>2003-07-09 23:40:23 +0800
committerMike Kestner <mkestner@src.gnome.org>2003-07-09 23:40:23 +0800
commit447b846a9bcdae02a550726d31afbf648c1eaafa (patch)
treefe03169dc1b6c1926a10685c290239518d45ed99 /e-util
parent9b7443310d9060ccfd8e2e782557cd9a5ec76f85 (diff)
downloadgsoc2013-evolution-447b846a9bcdae02a550726d31afbf648c1eaafa.tar
gsoc2013-evolution-447b846a9bcdae02a550726d31afbf648c1eaafa.tar.gz
gsoc2013-evolution-447b846a9bcdae02a550726d31afbf648c1eaafa.tar.bz2
gsoc2013-evolution-447b846a9bcdae02a550726d31afbf648c1eaafa.tar.lz
gsoc2013-evolution-447b846a9bcdae02a550726d31afbf648c1eaafa.tar.xz
gsoc2013-evolution-447b846a9bcdae02a550726d31afbf648c1eaafa.tar.zst
gsoc2013-evolution-447b846a9bcdae02a550726d31afbf648c1eaafa.zip
check null after conversions. (e_utf8_strftime_fix_am_pm): ditto. fixes
2003-07-09 Mike Kestner <mkestner@ximian.com> * 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
Diffstat (limited to 'e-util')
-rw-r--r--e-util/e-util.c46
1 files changed, 38 insertions, 8 deletions
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);