1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-04 08:43:13 +02:00

core: check pointer returned by function localtime

This commit is contained in:
Sebastien Helleu
2011-11-27 11:48:35 +01:00
parent 8ba8e62580
commit 41b5ef1e4c
16 changed files with 133 additions and 43 deletions
+10 -2
View File
@@ -4706,15 +4706,19 @@ weechat_guile_api_infolist_time (SCM infolist, SCM variable)
{
char timebuffer[64], *result;
time_t time;
struct tm *date_tmp;
SCM return_value;
API_FUNC(1, "infolist_time", API_RETURN_EMPTY);
if (!scm_is_string (infolist) || !scm_is_string (variable))
API_WRONG_ARGS(API_RETURN_EMPTY);
timebuffer[0] = '\0';
time = weechat_infolist_time (script_str2ptr (scm_i_string_chars (infolist)),
scm_i_string_chars (variable));
strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time));
date_tmp = localtime (&time);
if (date_tmp)
strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp);
result = strdup (timebuffer);
API_RETURN_STRING_FREE(result);
@@ -4976,16 +4980,20 @@ weechat_guile_api_hdata_time (SCM hdata, SCM pointer, SCM name)
{
char timebuffer[64], *result;
time_t time;
struct tm *date_tmp;
SCM return_value;
API_FUNC(1, "hdata_time", API_RETURN_EMPTY);
if (!scm_is_string (hdata) || !scm_is_string (pointer) || !scm_is_string (name))
API_WRONG_ARGS(API_RETURN_EMPTY);
timebuffer[0] = '\0';
time = weechat_hdata_time (script_str2ptr (scm_i_string_chars (hdata)),
script_str2ptr (scm_i_string_chars (pointer)),
scm_i_string_chars (name));
strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time));
date_tmp = localtime (&time);
if (date_tmp)
strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp);
result = strdup (timebuffer);
API_RETURN_STRING_FREE(result);