@@ -155,50 +155,52 @@ static void magic_set_error (int type, const char * format, ...) {
155
155
va_list args ;
156
156
char * buffer = NULL ;
157
157
int buffer_len = 0 ;
158
+ size_t maxlen = 0 ;
158
159
#if PHP_VERSION_ID >= 80000
159
160
zend_string * zbuffer ;
160
161
#endif
161
162
162
163
// php_error_cb in main.c
163
164
va_start (args , format );
164
- buffer_len = vspprintf (& buffer , PG (log_errors_max_len ), format , args );
165
+ #if PHP_VERSION_ID < 80100
166
+ maxlen = PG (log_errors_max_len );
167
+ #endif
168
+ buffer_len = vspprintf (& buffer , maxlen , format , args );
165
169
va_end (args );
166
170
167
171
#if PHP_VERSION_ID >= 80000
168
172
zbuffer = zend_string_init (buffer , buffer_len , 0 );
169
173
#endif
170
174
171
- #if PHP_VERSION_ID >= 80000
172
- if (PG (last_error_message )) {
173
- zend_string_release (PG (last_error_message ));
174
- PG (last_error_message ) = NULL ;
175
- }
176
- if (PG (last_error_file )) {
177
- free (PG (last_error_file ));
178
- PG (last_error_file ) = NULL ;
179
- }
180
- #else
181
175
if ( PG (last_error_message ) ) {
182
- #if PHP_VERSION_ID >= 70200
183
- char * s = PG (last_error_message );
184
- PG (last_error_message ) = NULL ;
176
+ #if PHP_VERSION_ID >= 80000
177
+ zend_string_release (PG (last_error_message ));
178
+ #elif PHP_VERSION_ID >= 70200
179
+ char * s = PG (last_error_message );
180
+ PG (last_error_message ) = NULL ;
185
181
free (s );
186
- #else
182
+ #else
187
183
free (PG (last_error_message ));
188
- PG (last_error_message ) = NULL ;
189
- #endif
190
- }
191
- if ( PG (last_error_file ) ) {
192
- #if PHP_VERSION_ID >= 70200
193
- char * s = PG (last_error_file );
184
+ #endif
194
185
PG (last_error_file ) = NULL ;
186
+ }
187
+
188
+ if ( PG (last_error_file ) ) {
189
+ #if PHP_VERSION_ID >= 80100
190
+ zend_string_release (PG (last_error_file ));
191
+ #elif PHP_VERSION_ID >= 80000
192
+ free (PG (last_error_file ));
193
+ #elif PHP_VERSION_ID >= 70200
194
+ char * s = PG (last_error_file );
195
+ PG (last_error_file ) = NULL ;
195
196
free (s );
196
- #else
197
+ #else
197
198
free (PG (last_error_file ));
199
+ #endif
198
200
PG (last_error_file ) = NULL ;
199
- #endif
200
201
}
201
- #endif
202
+
203
+
202
204
PG (last_error_lineno ) = 0 ;
203
205
204
206
/*
@@ -215,10 +217,18 @@ static void magic_set_error (int type, const char * format, ...) {
215
217
PG (last_error_message ) = strdup (buffer );
216
218
#endif
217
219
if ( zend_is_compiling () ) {
220
+ #if PHP_VERSION_ID >= 80100
221
+ PG (last_error_file ) = zend_string_copy (zend_get_compiled_filename ());
222
+ #else
218
223
PG (last_error_file ) = strdup (ZSTR_VAL (zend_get_compiled_filename ()));
224
+ #endif
219
225
PG (last_error_lineno ) = zend_get_compiled_lineno ();
220
226
} else if ( zend_is_executing () ) {
227
+ #if PHP_VERSION_ID >= 80100
228
+ PG (last_error_file ) = zend_string_copy (zend_get_executed_filename_ex ());
229
+ #else
221
230
PG (last_error_file ) = strdup (zend_get_executed_filename ());
231
+ #endif
222
232
PG (last_error_lineno ) = zend_get_executed_lineno ();
223
233
}
224
234
0 commit comments