diff --git a/fm-common/sources/fmDbUtils.cpp b/fm-common/sources/fmDbUtils.cpp index 90160f3a..3241e081 100644 --- a/fm-common/sources/fmDbUtils.cpp +++ b/fm-common/sources/fmDbUtils.cpp @@ -160,20 +160,21 @@ bool fm_db_util_get_timestamp(const char *str, FMTimeT &ft){ struct timespec ts; memset(&ts, 0, sizeof(ts)); // only check if the year is present - if (strlen(str) < 10){ + if (strlen(str) < 10) { //get the current time clock_gettime(CLOCK_REALTIME, &ts); - }else{ + }else { struct tm t; memset(&t, 0, sizeof(t)); strptime(str, "%F %T", &t); ts.tv_sec = mktime(&t); //now get the nanoseconds char *tstr = strdup(str); - strsep(&tstr, "."); - if (tstr != NULL){ + char *tobe_free = strsep(&tstr, "."); + if (tstr != NULL) { ts.tv_nsec = atol(tstr)*1000; } + free(tobe_free); } ft = ts.tv_sec*1000000 + ts.tv_nsec/1000; return true; @@ -352,7 +353,7 @@ bool fm_db_util_event_log_build_sql_insert(std::map &ma param.assign(str); cmd_params += param; } - + cmd_params.resize(cmd_params.size()-1); params.db_cmd = "INSERT INTO "; params.db_cmd += FM_EVENT_LOG_TABLE_NAME;