Project

General

Profile

Bug #5171 ยป 0001-ext-date-date_strftime.c-date_strftime_with_tmx-RB_G.patch

extra safety fix for tmx_zone - normalperson (Eric Wong), 08/09/2011 09:55 AM

View differences:

ext/date/date_core.c
6762 6762
    return INT2FIX(m_of(x));
6763 6763
}
6764 6764

  
6765
static char *
6766
tmx_m_zone(union DateData *x)
6767
{
6768
    return RSTRING_PTR(m_zone(x));
6769
}
6770

  
6771 6765
static struct tmx_funcs tmx_funcs = {
6772 6766
    (VALUE (*)(void *))m_real_year,
6773 6767
    (int (*)(void *))m_yday,
......
6786 6780
    (VALUE (*)(void *))tmx_m_secs,
6787 6781
    (VALUE (*)(void *))tmx_m_msecs,
6788 6782
    (VALUE (*)(void *))tmx_m_of,
6789
    (char *(*)(void *))tmx_m_zone
6783
    (VALUE (*)(void *))m_zone
6790 6784
};
6791 6785

  
6792 6786
static void
ext/date/date_strftime.c
183 183
	int precision, flags, colons;
184 184
	char padding;
185 185
	enum {LEFT, CHCASE, LOWER, UPPER, LOCALE_O, LOCALE_E};
186
	VALUE zone;
186 187
#define BIT_OF(n) (1U<<(n))
187 188

  
188 189
	/* various tables, useful in North America */
......
555 556
				flags &= ~(BIT_OF(UPPER)|BIT_OF(CHCASE));
556 557
				flags |= BIT_OF(LOWER);
557 558
			}
558
			{
559
				char *zone = tmx_zone;
560
				if (zone == NULL)
561
					tp = "";
562
				else
563
					tp = zone;
564
				i = strlen(tp);
565
			}
559
			zone = tmx_zone;
560

  
561
			RB_GC_GUARD(zone); /* not needed as of 2011-08-08 */
562
			tp = RSTRING_PTR(zone);
563
			i = RSTRING_LEN(zone);
566 564
			break;
567 565

  
568 566
#ifdef SYSV_EXT