Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit a7c04e0

Browse files
committed
[Bug 15090] Better definition of nil fixes crashes in 64-bit iOS
1 parent 6b551b9 commit a7c04e0

File tree

3 files changed

+56
-6
lines changed

3 files changed

+56
-6
lines changed

engine/src/mbliphonegfx.mm

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,9 +608,8 @@ - (id)initWithFrame:(CGRect)p_frame
608608
t_layer = (CAEAGLLayer *)[self layer];
609609

610610
[t_layer setOpaque: YES];
611-
// PM-2015-03-30: [[ Bug 15090 ]] Cast the last nil sentinel to prevent crash when setting the acceletaredRendering to true on openCard/openStack handler. The crash occured only in 64 bit iOS devices
612611
[t_layer setDrawableProperties:
613-
[NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, (NSString*)nil]];
612+
[NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil]];
614613

615614
// Initialize the context
616615

engine/src/typedefs.h

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,46 @@ typedef uint32_t codepoint_t;
182182
#endif
183183

184184
// Null pointer defines (nil is preferred)
185-
185+
// PM-2015-03-31: [[ Bug 15090 ]] Better definition of nil/NULL fixes crashes in 64 bit iOS
186186
#ifndef NULL
187-
#define NULL 0
187+
188+
#if defined(__cplusplus) /* C++ */
189+
# if defined(__GCC__)
190+
# define NULL __null
191+
# else
192+
# define NULL uintptr_t(0)
193+
# endif
194+
195+
#else /* C */
196+
# if defined(__GCC__)
197+
# define NULL __null
198+
# else
199+
# define NULL ((void*)0)
200+
# endif
201+
202+
#endif
203+
204+
188205
#endif
189206

190207
#ifndef nil
191-
#define nil 0
208+
209+
#if defined(__cplusplus) /* C++ */
210+
# if defined(__GCC__)
211+
# define nil __null
212+
# else
213+
# define nil uintptr_t(0)
214+
# endif
215+
216+
#else /* C */
217+
# if defined(__GCC__)
218+
# define nil __null
219+
# else
220+
# define nil ((void*)0)
221+
# endif
222+
223+
#endif
224+
192225
#endif
193226

194227
// Boolean definitions

libcore/include/core.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,26 @@ typedef const struct __CFString * CFStringRef;
108108
typedef const struct __CFData * CFDataRef;
109109
#endif
110110

111+
// PM-2015-03-31: [[ Bug 15090 ]] Better definition of nil fixes crashes in 64 bit iOS
111112
#ifndef nil
112-
#define nil 0
113+
114+
#if defined(__cplusplus) /* C++ */
115+
# if defined(__GCC__)
116+
# define nil __null
117+
# else
118+
# define nil uintptr_t(0)
119+
# endif
120+
121+
#else /* C */
122+
# if defined(__GCC__)
123+
# define nil __null
124+
# else
125+
# define nil ((void*)0)
126+
# endif
127+
128+
#endif
129+
130+
113131
#endif
114132

115133
#if defined(_MACOSX) && defined(__LP64__)

0 commit comments

Comments
 (0)