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/python | |
parent | 8ba8e625800462b060bc9e0cfc73dd05059c1f59 (diff) | |
download | weechat-41b5ef1e4cc6a28bd7274a016d83c95a93656248.zip |
core: check pointer returned by function localtime
Diffstat (limited to 'src/plugins/scripts/python')
-rw-r--r-- | src/plugins/scripts/python/weechat-python-api.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/plugins/scripts/python/weechat-python-api.c b/src/plugins/scripts/python/weechat-python-api.c index 18b826ee6..c02716c73 100644 --- a/src/plugins/scripts/python/weechat-python-api.c +++ b/src/plugins/scripts/python/weechat-python-api.c @@ -5104,6 +5104,7 @@ weechat_python_api_infolist_time (PyObject *self, PyObject *args) { char *infolist, *variable, timebuffer[64], *result; time_t time; + struct tm *date_tmp; PyObject *return_value; API_FUNC(1, "infolist_time", API_RETURN_EMPTY); @@ -5112,9 +5113,12 @@ weechat_python_api_infolist_time (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "ss", &infolist, &variable)) API_WRONG_ARGS(API_RETURN_EMPTY); + 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); @@ -5405,6 +5409,7 @@ weechat_python_api_hdata_time (PyObject *self, PyObject *args) { char *hdata, *pointer, *name, timebuffer[64], *result; time_t time; + struct tm *date_tmp; PyObject *return_value; API_FUNC(1, "hdata_time", API_RETURN_EMPTY); @@ -5414,10 +5419,13 @@ weechat_python_api_hdata_time (PyObject *self, PyObject *args) if (!PyArg_ParseTuple (args, "sss", &hdata, &pointer, &name)) API_WRONG_ARGS(API_RETURN_EMPTY); + 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); |