make test for matlab files more specific
Previously vips just called Mat_Open() to test if a file was a Matlab save file, but this is rather unreliable. For example, some JPEG files can crash libmatio, and it can incorrectly think that at least some JP2 files are Matlab save files. Instead, look for "MATLAB 5.0" at the start of the file. This is really too specific, the first 116 bytes of a Matlab save file are freeform text, but in practice all Matlab writers use the first few bytes to record the file type. See https://github.com/jcupitt/libvips/issues/385
This commit is contained in:
parent
f131aaa082
commit
ef6d8f5979
@ -4,6 +4,7 @@
|
|||||||
- bicubic is better on 32-bit int images
|
- bicubic is better on 32-bit int images
|
||||||
- add pdfload, svgload, gifload for PDF, SVG and GIF rendering
|
- add pdfload, svgload, gifload for PDF, SVG and GIF rendering
|
||||||
- vipsthumbnail knows about pdfload and svgload
|
- vipsthumbnail knows about pdfload and svgload
|
||||||
|
- matload is more specific (thanks bithive)
|
||||||
|
|
||||||
27/1/16 started 8.2.3
|
27/1/16 started 8.2.3
|
||||||
- fix a crash with SPARC byte-order labq vips images
|
- fix a crash with SPARC byte-order labq vips images
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
* 21/8/14
|
* 21/8/14
|
||||||
* - swap width/height
|
* - swap width/height
|
||||||
* - set interpretation to rgb16 etc.
|
* - set interpretation to rgb16 etc.
|
||||||
|
* 16/2/16
|
||||||
|
* - more specific is_a test
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -319,14 +321,13 @@ vips__mat_load( const char *filename, VipsImage *out )
|
|||||||
int
|
int
|
||||||
vips__mat_ismat( const char *filename )
|
vips__mat_ismat( const char *filename )
|
||||||
{
|
{
|
||||||
mat_t *mat;
|
unsigned char buf[15];
|
||||||
|
|
||||||
vips_error_freeze();
|
if( vips__get_bytes( filename, buf, 10 ) &&
|
||||||
mat = Mat_Open( filename, MAT_ACC_RDONLY );
|
vips_isprefix( "MATLAB 5.0", (char *) buf ) )
|
||||||
Mat_Close( mat );
|
return( 1 );
|
||||||
vips_error_thaw();
|
|
||||||
|
|
||||||
return( mat != NULL );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *vips__mat_suffs[] = { ".mat", NULL };
|
const char *vips__mat_suffs[] = { ".mat", NULL };
|
||||||
|
@ -122,11 +122,6 @@ vips_foreign_load_mat_class_init( VipsForeignLoadMatClass *class )
|
|||||||
|
|
||||||
foreign_class->suffs = vips__mat_suffs;
|
foreign_class->suffs = vips__mat_suffs;
|
||||||
|
|
||||||
/* We need to be lower priority than the jpeg loader, since some jpegs
|
|
||||||
* can make libmatio segv on Mat_Open().
|
|
||||||
*/
|
|
||||||
foreign_class->priority = -50;
|
|
||||||
|
|
||||||
load_class->is_a = vips__mat_ismat;
|
load_class->is_a = vips__mat_ismat;
|
||||||
load_class->get_flags_filename =
|
load_class->get_flags_filename =
|
||||||
vips_foreign_load_mat_get_flags_filename;
|
vips_foreign_load_mat_get_flags_filename;
|
||||||
|
Loading…
Reference in New Issue
Block a user