mirror of
https://github.com/mdbtools/mdbtools.git
synced 2025-12-21 19:10:05 +08:00
Better idea, return empty string at mdb_date_to_string().
This commit is contained in:
@@ -894,10 +894,6 @@ mdb_date_to_tm(double td, struct tm *t)
|
|||||||
long yr, q;
|
long yr, q;
|
||||||
const int *cal;
|
const int *cal;
|
||||||
|
|
||||||
// limit to ~1100AD--2700A to protect from overflow
|
|
||||||
if (td < -1e6 || td > 1e6)
|
|
||||||
return;
|
|
||||||
|
|
||||||
yr = 1;
|
yr = 1;
|
||||||
day = (long)(td);
|
day = (long)(td);
|
||||||
time = (long)((td - day) * 86400.0 + 0.5);
|
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);
|
char *text = g_malloc(mdb->bind_size);
|
||||||
double td = mdb_get_double(buf, start);
|
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);
|
strftime(text, mdb->bind_size, mdb->date_fmt, &t);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user