From 57cd54f654f6bffa36bfc8cd2865c45abeb73152 Mon Sep 17 00:00:00 2001 From: Andy Reagan Date: Fri, 3 Dec 2021 15:35:51 -0500 Subject: [PATCH] Better idea, return empty string at mdb_date_to_string(). --- src/libmdb/data.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/libmdb/data.c b/src/libmdb/data.c index 6850fab..b2f1de1 100644 --- a/src/libmdb/data.c +++ b/src/libmdb/data.c @@ -894,10 +894,6 @@ mdb_date_to_tm(double td, struct tm *t) long yr, q; const int *cal; - // limit to ~1100AD--2700A to protect from overflow - if (td < -1e6 || td > 1e6) - return; - yr = 1; day = (long)(td); time = (long)((td - day) * 86400.0 + 0.5); @@ -944,9 +940,11 @@ mdb_date_to_string(MdbHandle *mdb, const char *fmt, void *buf, int start) char *text = g_malloc(mdb->bind_size); double td = mdb_get_double(buf, start); - mdb_date_to_tm(td, &t); + // limit to ~1100AD--2700A to protect from overflow + if (td < -1e6 || td > 1e6) + return strdup(""); - // check if t is still unchanged, return empty string? + mdb_date_to_tm(td, &t); strftime(text, mdb->bind_size, mdb->date_fmt, &t);