diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2011-11-27 11:48:35 +0100 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2011-11-27 11:48:35 +0100 |
commit | 41b5ef1e4cc6a28bd7274a016d83c95a93656248 (patch) | |
tree | a3df43ccbe1498745e84c6ccdc4f8db20e153f02 /src/plugins/scripts/ruby/weechat-ruby-api.c | |
parent | 8ba8e625800462b060bc9e0cfc73dd05059c1f59 (diff) | |
download | weechat-41b5ef1e4cc6a28bd7274a016d83c95a93656248.zip |
core: check pointer returned by function localtime
Diffstat (limited to 'src/plugins/scripts/ruby/weechat-ruby-api.c')
-rw-r--r-- | src/plugins/scripts/ruby/weechat-ruby-api.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/plugins/scripts/ruby/weechat-ruby-api.c b/src/plugins/scripts/ruby/weechat-ruby-api.c index 5d9b0478b..3ffb20bdf 100644 --- a/src/plugins/scripts/ruby/weechat-ruby-api.c +++ b/src/plugins/scripts/ruby/weechat-ruby-api.c @@ -5857,6 +5857,7 @@ weechat_ruby_api_infolist_time (VALUE class, VALUE infolist, VALUE variable) { char *c_infolist, *c_variable, timebuffer[64], *result; time_t time; + struct tm *date_tmp; VALUE return_value; API_FUNC(1, "infolist_time", API_RETURN_EMPTY); @@ -5869,8 +5870,11 @@ weechat_ruby_api_infolist_time (VALUE class, VALUE infolist, VALUE variable) c_infolist = StringValuePtr (infolist); c_variable = StringValuePtr (variable); + timebuffer[0] = '\0'; time = weechat_infolist_time (script_str2ptr (c_infolist), c_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); @@ -6221,6 +6225,7 @@ weechat_ruby_api_hdata_time (VALUE class, VALUE hdata, VALUE pointer, { char *c_hdata, *c_pointer, *c_name, timebuffer[64], *result; time_t time; + struct tm *date_tmp; VALUE return_value; API_FUNC(1, "hdata_time", API_RETURN_EMPTY); @@ -6235,10 +6240,13 @@ weechat_ruby_api_hdata_time (VALUE class, VALUE hdata, VALUE pointer, c_pointer = StringValuePtr (pointer); c_name = StringValuePtr (name); + timebuffer[0] = '\0'; time = weechat_hdata_time (script_str2ptr (c_hdata), script_str2ptr (c_pointer), c_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); |