Index: ext/date/lib/parse_tz.c =================================================================== RCS file: /repository/php-src/ext/date/lib/parse_tz.c,v retrieving revision 1.20.2.6.2.13.2.3 diff -u -p -r1.20.2.6.2.13.2.3 parse_tz.c --- ext/date/lib/parse_tz.c 18 Jul 2008 14:33:53 -0000 1.20.2.6.2.13.2.3 +++ ext/date/lib/parse_tz.c 9 Aug 2008 21:52:03 -0000 @@ -143,46 +143,52 @@ static void read_types(char **tzf, timel memcpy(tz->timezone_abbr, *tzf, sizeof(char) * tz->charcnt); *tzf += sizeof(char) * tz->charcnt; - leap_buffer = (int32_t *) malloc(tz->leapcnt * 2 * sizeof(int32_t)); - if (!leap_buffer) { - return; - } - memcpy(leap_buffer, *tzf, sizeof(int32_t) * tz->leapcnt * 2); - *tzf += sizeof(int32_t) * tz->leapcnt * 2; - - tz->leap_times = (tlinfo*) malloc(tz->leapcnt * sizeof(tlinfo)); - if (!tz->leap_times) { - return; - } - for (i = 0; i < tz->leapcnt; i++) { - tz->leap_times[i].trans = timelib_conv_int(leap_buffer[i * 2]); - tz->leap_times[i].offset = timelib_conv_int(leap_buffer[i * 2 + 1]); - } - free(leap_buffer); - - buffer = (unsigned char*) malloc(tz->ttisstdcnt * sizeof(unsigned char)); - if (!buffer) { - return; - } - memcpy(buffer, *tzf, sizeof(unsigned char) * tz->ttisstdcnt); - *tzf += sizeof(unsigned char) * tz->ttisstdcnt; + if (tz->leapcnt) { + leap_buffer = (int32_t *) malloc(tz->leapcnt * 2 * sizeof(int32_t)); + if (!leap_buffer) { + return; + } + memcpy(leap_buffer, *tzf, sizeof(int32_t) * tz->leapcnt * 2); + *tzf += sizeof(int32_t) * tz->leapcnt * 2; - for (i = 0; i < tz->ttisstdcnt; i++) { - tz->type[i].isstdcnt = buffer[i]; + tz->leap_times = (tlinfo*) malloc(tz->leapcnt * sizeof(tlinfo)); + if (!tz->leap_times) { + return; + } + for (i = 0; i < tz->leapcnt; i++) { + tz->leap_times[i].trans = timelib_conv_int(leap_buffer[i * 2]); + tz->leap_times[i].offset = timelib_conv_int(leap_buffer[i * 2 + 1]); + } + free(leap_buffer); } - free(buffer); - buffer = (unsigned char*) malloc(tz->ttisgmtcnt * sizeof(unsigned char)); - if (!buffer) { - return; + if (tz->ttisstdcnt) { + buffer = (unsigned char*) malloc(tz->ttisstdcnt * sizeof(unsigned char)); + if (!buffer) { + return; + } + memcpy(buffer, *tzf, sizeof(unsigned char) * tz->ttisstdcnt); + *tzf += sizeof(unsigned char) * tz->ttisstdcnt; + + for (i = 0; i < tz->ttisstdcnt; i++) { + tz->type[i].isstdcnt = buffer[i]; + } + free(buffer); } - memcpy(buffer, *tzf, sizeof(unsigned char) * tz->ttisgmtcnt); - *tzf += sizeof(unsigned char) * tz->ttisgmtcnt; - for (i = 0; i < tz->ttisgmtcnt; i++) { - tz->type[i].isgmtcnt = buffer[i]; + if (tz->ttisgmtcnt) { + buffer = (unsigned char*) malloc(tz->ttisgmtcnt * sizeof(unsigned char)); + if (!buffer) { + return; + } + memcpy(buffer, *tzf, sizeof(unsigned char) * tz->ttisgmtcnt); + *tzf += sizeof(unsigned char) * tz->ttisgmtcnt; + + for (i = 0; i < tz->ttisgmtcnt; i++) { + tz->type[i].isgmtcnt = buffer[i]; + } + free(buffer); } - free(buffer); } static void read_location(char **tzf, timelib_tzinfo *tz)