From 04828e628a970d15f0286712a4b37f7af6a75560 Mon Sep 17 00:00:00 2001 From: Tomas Mlcoch Date: Tue, 31 Jan 2017 10:07:14 +0100 Subject: [PATCH] updaterecord-py.c: Fix SIGSEGV during date-time parsing (#72) --- src/python/updaterecord-py.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/python/updaterecord-py.c b/src/python/updaterecord-py.c index 6c5a4fd..4ea4094 100644 --- a/src/python/updaterecord-py.c +++ b/src/python/updaterecord-py.c @@ -272,14 +272,14 @@ get_datetime(_UpdateRecordObject *self, void *member_offset) if (str == NULL) Py_RETURN_NONE; - struct tm *dt = malloc(sizeof(struct tm)); + struct tm *dt = g_malloc0(sizeof(struct tm)); char *res = strptime(str, "%Y-%m-%d %H:%M:%S", dt); if (res == NULL) { - memset(res,0,sizeof(dt)); + memset(dt, 0, sizeof(struct tm)); res = strptime(str, "%Y-%m-%d", dt); if (res == NULL) PyErr_SetString(CrErr_Exception, "Invalid date"); - } + } PyObject *py_dt = PyDateTime_FromDateAndTime(dt->tm_year + 1900, dt->tm_mon + 1, dt->tm_mday, dt->tm_hour, dt->tm_min, dt->tm_sec, 0); -- 2.34.1