1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-27 05:16:38 +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);
+10 -2
View File
@@ -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);
+11 -2
View File
@@ -4922,6 +4922,7 @@ XS (XS_weechat_api_infolist_pointer)
XS (XS_weechat_api_infolist_time)
{
time_t time;
struct tm *date_tmp;
char timebuffer[64], *result, *infolist, *variable;
dXSARGS;
@@ -4931,8 +4932,12 @@ XS (XS_weechat_api_infolist_time)
infolist = SvPV_nolen (ST (0));
variable = SvPV_nolen (ST (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);
@@ -5224,6 +5229,7 @@ XS (XS_weechat_api_hdata_pointer)
XS (XS_weechat_api_hdata_time)
{
time_t time;
struct tm *date_tmp;
char timebuffer[64], *result, *hdata, *pointer, *name;
dXSARGS;
@@ -5235,10 +5241,13 @@ XS (XS_weechat_api_hdata_time)
pointer = SvPV_nolen (ST (1));
name = SvPV_nolen (ST (2));
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);
@@ -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);
+10 -2
View File
@@ -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);
+11 -4
View File
@@ -5607,6 +5607,7 @@ weechat_tcl_api_infolist_time (ClientData clientData, Tcl_Interp *interp,
{
Tcl_Obj *objp;
time_t time;
struct tm *date_tmp;
char timebuffer[64], *result, *infolist, *variable;
int i;
@@ -5616,9 +5617,12 @@ weechat_tcl_api_infolist_time (ClientData clientData, Tcl_Interp *interp,
infolist = Tcl_GetStringFromObj (objv[1], &i);
variable = Tcl_GetStringFromObj (objv[2], &i);
time = weechat_infolist_time (script_str2ptr (infolist), variable);
strftime (timebuffer, sizeof (timebuffer), "%F %T", localtime (&time));
timebuffer[0] = '\0';
time = weechat_infolist_time (script_str2ptr (infolist), variable);
date_tmp = localtime (&time);
if (date_tmp)
strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp);
result = strdup (timebuffer);
API_RETURN_STRING_FREE(result);
@@ -5921,6 +5925,7 @@ weechat_tcl_api_hdata_time (ClientData clientData, Tcl_Interp *interp,
{
Tcl_Obj *objp;
time_t time;
struct tm *date_tmp;
char timebuffer[64], *result, *hdata, *pointer, *name;
int i;
@@ -5932,11 +5937,13 @@ weechat_tcl_api_hdata_time (ClientData clientData, Tcl_Interp *interp,
pointer = Tcl_GetStringFromObj (objv[2], &i);
name = Tcl_GetStringFromObj (objv[3], &i);
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);