@@ -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,19 @@ PHP_FUNCTION(finfo_file)
317
313
}
318
314
319
315
/* Set options for the current file/buffer. */
316
+ int old_options ;
320
317
if (options ) {
318
+ old_options = magic_getflags (magic );
321
319
/* We do not check the return value as it can only ever fail if options contains MAGIC_PRESERVE_ATIME
322
320
* and the system neither has utime(3) nor utimes(2). Something incredibly unlikely. */
323
321
magic_setflags (magic , options );
324
322
}
325
323
326
324
const char * ret_val = php_fileinfo_from_path (magic , path , context );
325
+
327
326
/* Restore options */
328
327
if (options ) {
329
- magic_setflags (magic , Z_FINFO_P ( self ) -> options );
328
+ magic_setflags (magic , old_options );
330
329
}
331
330
332
331
if (UNEXPECTED (ret_val == NULL )) {
@@ -351,15 +350,19 @@ PHP_FUNCTION(finfo_buffer)
351
350
struct magic_set * magic = Z_FINFO_P (self )-> magic ;
352
351
353
352
/* Set options for the current file/buffer. */
353
+ int old_options ;
354
354
if (options ) {
355
+ old_options = magic_getflags (magic );
356
+ /* We do not check the return value as it can only ever fail if options contains MAGIC_PRESERVE_ATIME
357
+ * and the system neither has utime(3) nor utimes(2). Something incredibly unlikely. */
355
358
magic_setflags (magic , options );
356
359
}
357
360
358
361
const char * ret_val = magic_buffer (magic , ZSTR_VAL (buffer ), ZSTR_LEN (buffer ));
359
362
360
363
/* Restore options */
361
364
if (options ) {
362
- magic_setflags (magic , Z_FINFO_P ( self ) -> options );
365
+ magic_setflags (magic , old_options );
363
366
}
364
367
365
368
if (UNEXPECTED (ret_val == NULL )) {
0 commit comments