Skip to content

Commit 05bfcce

Browse files
committed
Use ZEND_THIS instead of getThis()
getThis() calls ZEND_THIS and returns NULL if it is not an object. We know that it is an object and if a NULL was returned, we'd be dereferencing NULL.
1 parent 76cd39e commit 05bfcce

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

ext/maxminddb.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ typedef zend_object free_obj_t;
6969
#define IS_MIXED IS_UNDEF
7070
#endif
7171

72+
/* ZEND_THIS was added in 7.4 */
73+
#ifndef ZEND_THIS
74+
#define ZEND_THIS (&EX(This))
75+
#endif
76+
7277
typedef struct _maxminddb_obj {
7378
MMDB_s *mmdb;
7479
zend_object std;
@@ -151,7 +156,7 @@ PHP_METHOD(MaxMind_Db_Reader, __construct) {
151156
return;
152157
}
153158

154-
maxminddb_obj *mmdb_obj = Z_MAXMINDDB_P(getThis());
159+
maxminddb_obj *mmdb_obj = Z_MAXMINDDB_P(ZEND_THIS);
155160
mmdb_obj->mmdb = mmdb;
156161
}
157162

@@ -202,7 +207,7 @@ get_record(INTERNAL_FUNCTION_PARAMETERS, zval *record, int *prefix_len) {
202207
return FAILURE;
203208
}
204209

205-
const maxminddb_obj *mmdb_obj = (maxminddb_obj *)Z_MAXMINDDB_P(getThis());
210+
const maxminddb_obj *mmdb_obj = (maxminddb_obj *)Z_MAXMINDDB_P(ZEND_THIS);
206211

207212
MMDB_s *mmdb = mmdb_obj->mmdb;
208213

0 commit comments

Comments
 (0)