[evolution-patches] 44904: crash in e_utf8_strftime_fix_am_pm
- From: Mike Kestner <mkestner ximian com>
- To: Evolution Patches <evolution-patches lists ximian com>
- Subject: [evolution-patches] 44904: crash in e_utf8_strftime_fix_am_pm
- Date: 07 Jul 2003 12:33:54 -0500
Adds guarding against locale -> utf8 -> locale conversion failures in
both e_utf8_strftime funcs. Since the stack trace had no symbols, I'm
just guessing this is the problem, but the checks are needed anyway.
Mike
Index: gal/util/e-util.c
===================================================================
RCS file: /cvs/gnome/gal/gal/util/e-util.c,v
retrieving revision 1.60
diff -u -p -r1.60 e-util.c
--- gal/util/e-util.c 31 May 2003 17:21:23 -0000 1.60
+++ gal/util/e-util.c 7 Jul 2003 17:18:46 -0000
@@ -771,10 +771,25 @@ size_t e_strftime(char *s, size_t max, c
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, siz
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]