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
This commit is contained in:

committed by
Mike Kestner

parent
9b7443310d
commit
447b846a9b
@ -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);
|
||||
|
Reference in New Issue
Block a user