/* figure out the GMT offset */
stamp = time(NULL);
gmt = php_gmtime_r(&stamp, &tmbuf);
+ if (!gmt) {
+ return -1;
+ }
gmt->tm_isdst = -1;
/* apply the GMT offset */
case SQL_TYPE_DATE:
case SQL_TYPE_TIME:
if (Z_TYPE_P(b_var) == IS_LONG) {
- php_gmtime_r(&Z_LVAL_P(b_var), &t);
+ struct tm *res;
+ res = php_gmtime_r(&Z_LVAL_P(b_var), &t);
+ if (!res) {
+ return FAILURE;
+ }
} else {
#ifdef HAVE_STRPTIME
char *format = INI_STR("ibase.timestampformat");
static inline void strcpy_gmt(char *ubuf, time_t *when)
{
char buf[MAX_STR];
- struct tm tm;
+ struct tm tm, *res;
int n;
- php_gmtime_r(when, &tm);
+ res = php_gmtime_r(when, &tm);
+ if (!res) {
+ buf[0] = '\0';
+ return;
+ }
+
n = snprintf(buf, sizeof(buf), "%s, %02d %s %d %02d:%02d:%02d GMT", /* SAFE */
week_days[tm.tm_wday], tm.tm_mday,
month_names[tm.tm_mon], tm.tm_year + 1900,
tm1 = php_gmtime_r(&t, &tmbuf);
str = emalloc(81);
+ str[0] = '\0';
+
+ if (!tm1) {
+ return str;
+ }
+
if (PG(y2k_compliance)) {
snprintf(str, 80, "%s, %02d %s %04d %02d:%02d:%02d GMT",
day_short_names[tm1->tm_wday],
/* figure out the GMT offset */
stamp = time(NULL);
gmt = php_gmtime_r(&stamp, &tmbuf);
+ if (!gmt) {
+ goto mdtm_error;
+ }
gmt->tm_isdst = -1;
/* apply the GMT offset */