@@ -40,7 +40,6 @@ static zend_object_handlers finfo_object_handlers;
40
40
zend_class_entry * finfo_class_entry ;
41
41
42
42
typedef struct _finfo_object {
43
- zend_long options ;
44
43
struct magic_set * magic ;
45
44
zend_object zo ;
46
45
} finfo_object ;
@@ -203,12 +202,10 @@ PHP_FUNCTION(finfo_open)
203
202
zend_restore_error_handling (& zeh );
204
203
finfo_object * obj = Z_FINFO_P (object );
205
204
obj -> magic = magic ;
206
- obj -> options = options ;
207
205
} else {
208
206
zend_object * zobj = finfo_objects_new (finfo_class_entry );
209
207
finfo_object * obj = php_finfo_fetch_object (zobj );
210
208
obj -> magic = magic ;
211
- obj -> options = options ;
212
209
RETURN_OBJ (zobj );
213
210
}
214
211
}
@@ -240,7 +237,6 @@ PHP_FUNCTION(finfo_set_flags)
240
237
/* We do not check the return value as it can only ever fail if options contains MAGIC_PRESERVE_ATIME
241
238
* and the system neither has utime(3) nor utimes(2). Something incredibly unlikely. */
242
239
magic_setflags (Z_FINFO_P (self )-> magic , options );
243
- Z_FINFO_P (self )-> options = options ;
244
240
245
241
RETURN_TRUE ;
246
242
}
@@ -317,16 +313,18 @@ PHP_FUNCTION(finfo_file)
317
313
}
318
314
319
315
/* Set options for the current file/buffer. */
316
+ int old_options = magic_getflags (magic );
320
317
if (options ) {
321
318
/* We do not check the return value as it can only ever fail if options contains MAGIC_PRESERVE_ATIME
322
319
* and the system neither has utime(3) nor utimes(2). Something incredibly unlikely. */
323
320
magic_setflags (magic , options );
324
321
}
325
322
326
323
const char * ret_val = php_fileinfo_from_path (magic , path , context );
324
+
327
325
/* Restore options */
328
326
if (options ) {
329
- magic_setflags (magic , Z_FINFO_P ( self ) -> options );
327
+ magic_setflags (magic , old_options );
330
328
}
331
329
332
330
if (UNEXPECTED (ret_val == NULL )) {
@@ -351,15 +349,18 @@ PHP_FUNCTION(finfo_buffer)
351
349
struct magic_set * magic = Z_FINFO_P (self )-> magic ;
352
350
353
351
/* Set options for the current file/buffer. */
352
+ int old_options = magic_getflags (magic );
354
353
if (options ) {
354
+ /* We do not check the return value as it can only ever fail if options contains MAGIC_PRESERVE_ATIME
355
+ * and the system neither has utime(3) nor utimes(2). Something incredibly unlikely. */
355
356
magic_setflags (magic , options );
356
357
}
357
358
358
359
const char * ret_val = magic_buffer (magic , ZSTR_VAL (buffer ), ZSTR_LEN (buffer ));
359
360
360
361
/* Restore options */
361
362
if (options ) {
362
- magic_setflags (magic , Z_FINFO_P ( self ) -> options );
363
+ magic_setflags (magic , old_options );
363
364
}
364
365
365
366
if (UNEXPECTED (ret_val == NULL )) {
0 commit comments