summaryrefslogtreecommitdiff
path: root/src/plugins/scripts/lua
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2011-11-27 11:48:35 +0100
committerSebastien Helleu <flashcode@flashtux.org>2011-11-27 11:48:35 +0100
commit41b5ef1e4cc6a28bd7274a016d83c95a93656248 (patch)
treea3df43ccbe1498745e84c6ccdc4f8db20e153f02 /src/plugins/scripts/lua
parent8ba8e625800462b060bc9e0cfc73dd05059c1f59 (diff)
downloadweechat-41b5ef1e4cc6a28bd7274a016d83c95a93656248.zip
core: check pointer returned by function localtime
Diffstat (limited to 'src/plugins/scripts/lua')
-rw-r--r--src/plugins/scripts/lua/weechat-lua-api.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/plugins/scripts/lua/weechat-lua-api.c b/src/plugins/scripts/lua/weechat-lua-api.c
index 24ccbce6d..a9d3ed861 100644
--- a/src/plugins/scripts/lua/weechat-lua-api.c
+++ b/src/plugins/scripts/lua/weechat-lua-api.c
@@ -5179,6 +5179,7 @@ weechat_lua_api_infolist_time (lua_State *L)
{
const char *infolist, *variable;
time_t time;
+ struct tm *date_tmp;
char timebuffer[64], *result;
API_FUNC(1, "infolist_time", API_RETURN_EMPTY);
@@ -5188,9 +5189,12 @@ weechat_lua_api_infolist_time (lua_State *L)
infolist = lua_tostring (lua_current_interpreter, -2);
variable = lua_tostring (lua_current_interpreter, -1);
+ timebuffer[0] = '\0';
time = weechat_infolist_time (script_str2ptr (infolist),
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);
@@ -5490,6 +5494,7 @@ weechat_lua_api_hdata_time (lua_State *L)
{
const char *hdata, *pointer, *name;
time_t time;
+ struct tm *date_tmp;
char timebuffer[64], *result;
API_FUNC(1, "hdata_time", API_RETURN_EMPTY);
@@ -5500,10 +5505,13 @@ weechat_lua_api_hdata_time (lua_State *L)
pointer = lua_tostring (lua_current_interpreter, -2);
name = lua_tostring (lua_current_interpreter, -1);
+ timebuffer[0] = '\0';
time = weechat_hdata_time (script_str2ptr (hdata),
script_str2ptr (pointer),
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);