stop jxl header decode earlier
Previously, jxl header decode waited for JXL_DEC_NEED_IMAGE_OUT_BUFFER status. But libjxl will actually allocate a lot of memory for decode before this point, and this exposes jxlload to memory bombs. This patch stops after JXL_DEC_COLOR_ENCODING, ie. just after the last section before pixel data. This lets us get all image metadata, but does no pixel buffer allocation.
This commit is contained in:
parent
41cff4e9d0
commit
37988cef83
@ -547,6 +547,11 @@ vips_foreign_load_jxl_header( VipsForeignLoad *load )
|
||||
"JxlDecoderGetICCProfileSize" );
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
printf( "vips_foreign_load_jxl_header: "
|
||||
"%zd byte profile\n", jxl->icc_size );
|
||||
#endif /*DEBUG*/
|
||||
if( !(jxl->icc_data = vips_malloc( NULL,
|
||||
jxl->icc_size )) )
|
||||
return( -1 );
|
||||
@ -564,7 +569,10 @@ vips_foreign_load_jxl_header( VipsForeignLoad *load )
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} while( status != JXL_DEC_NEED_IMAGE_OUT_BUFFER );
|
||||
/* JXL_DEC_COLOR_ENCODING is always the last status signal before
|
||||
* pixel decoding starts.
|
||||
*/
|
||||
} while( status != JXL_DEC_COLOR_ENCODING );
|
||||
|
||||
if( vips_foreign_load_jxl_set_header( jxl, load->out ) )
|
||||
return( -1 );
|
||||
|
Loading…
Reference in New Issue
Block a user