From 08ae88157b4f73154b2f1ffe72c3957edb3772fc Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 23 Apr 2014 19:05:16 +0200 Subject: Allocate zend_strings with correct size For me (32bit) sizeof(zend_string) is 20, which means that the char[1] array at the end is padded with three bytes. Thus allocating based on sizeof(zend_string)-1 overallocates by those 3 padding bytes. This commit fixes the allocation size, by using XtOffsetOf. --- Zend/zend_ini.h | 30 ------------------------------ 1 file changed, 30 deletions(-) (limited to 'Zend/zend_ini.h') diff --git a/Zend/zend_ini.h b/Zend/zend_ini.h index 8782ec6f20..0a0c1137e1 100644 --- a/Zend/zend_ini.h +++ b/Zend/zend_ini.h @@ -27,36 +27,6 @@ #define ZEND_INI_ALL (ZEND_INI_USER|ZEND_INI_PERDIR|ZEND_INI_SYSTEM) -#ifndef XtOffsetOf -# if defined(CRAY) || (defined(__ARMCC_VERSION) && !defined(LINUX)) -# ifdef __STDC__ -# define XtOffset(p_type, field) _Offsetof(p_type, field) -# else -# ifdef CRAY2 -# define XtOffset(p_type, field) \ - (sizeof(int)*((unsigned int)&(((p_type)NULL)->field))) - -# else /* !CRAY2 */ - -# define XtOffset(p_type, field) ((unsigned int)&(((p_type)NULL)->field)) - -# endif /* !CRAY2 */ -# endif /* __STDC__ */ -# else /* ! (CRAY || __arm) */ - -# define XtOffset(p_type, field) \ - ((long) (((char *) (&(((p_type)NULL)->field))) - ((char *) NULL))) - -# endif /* !CRAY */ - -# ifdef offsetof -# define XtOffsetOf(s_type, field) offsetof(s_type, field) -# else -# define XtOffsetOf(s_type, field) XtOffset(s_type*, field) -# endif - -#endif - #define ZEND_INI_MH(name) int name(zend_ini_entry *entry, char *new_value, uint new_value_length, void *mh_arg1, void *mh_arg2, void *mh_arg3, int stage TSRMLS_DC) #define ZEND_INI_DISP(name) void name(zend_ini_entry *ini_entry, int type) -- cgit v1.2.1