Mercurial > pidgin
changeset 13715:f65e8d30ae53
[gaim-migrate @ 16123]
Fix a bug reported as SF Patch #1479875.
"in gaim_icqinfo() in oscar.c , the struct tm used for
filling in birthday date is not initialized, this cause
crash in strftime on amd64 which is indirectly called
by gaim_date_format_short. Reproduced on debian sarge
amd64 stable."
I chose a different solution than what was provided in the patch.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Tue, 02 May 2006 01:49:54 +0000 |
parents | 4cf1db3ffada |
children | 963703ee5f91 |
files | src/protocols/oscar/oscar.c |
diffstat | 1 files changed, 15 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/protocols/oscar/oscar.c Tue May 02 01:44:14 2006 +0000 +++ b/src/protocols/oscar/oscar.c Tue May 02 01:49:54 2006 +0000 @@ -3650,12 +3650,22 @@ if (info->gender != 0) oscar_string_append(gc->account, str, "\n<br>", _("Gender"), info->gender == 1 ? _("Female") : _("Male")); if ((info->birthyear > 1900) && (info->birthmonth > 0) && (info->birthday > 0)) { - struct tm tm; - tm.tm_mday = (int)info->birthday; - tm.tm_mon = (int)info->birthmonth-1; - tm.tm_year = (int)info->birthyear-1900; + /* Initialize the struct properly or strftime() will crash + * on some systems (Debian Sarge AMD64). */ + time_t t = time(NULL); + struct tm *tm = localtime(&t); + + tm->tm_mday = (int)info->birthday; + tm->tm_mon = (int)info->birthmonth - 1; + tm->tm_year = (int)info->birthyear - 1900; + + /* To be 100% sure that the fields are re-normalized. + * If you're sure strftime() ALWAYS does this EVERYWHERE, + * feel free to remove it. --rlaager */ + mktime(tm); + oscar_string_append(gc->account, str, "\n<br>", _("Birthday"), - gaim_date_format_short(&tm)); + gaim_date_format_short(tm)); } if ((info->age > 0) && (info->age < 255)) { char age[5];