[BZ#741393] SVG size limit error with specialized rsvg handle creation functions
Submitted by Mika Heiskanen
Link to original bug (#741393)
Description
A previous version added function rsvg_handle_new_with_flags which takes as input flags with which one can disable the 10 MB size limit for SVG files. However, no such alternate API was added for the other handle creation functions:
- rsvh_handle_new_from_gfile_sync
- rsvg_handle_new_from_stream_sync
- rsvg_handle_new_from_data
- rsvg_handle_new_from_file
For example, if one generates a > 10 MB SVG in memory, one would use rsvg_handle_new_from_data to convert it to other graphics format. However, the function will error since it uses internally rsvg_handle_new and there is thus no way to disable the memory limit.
As a quick test I have verified that the following additions work:
rsvg.h:
RsvgHandle *rsvg_handle_new_from_data_with_flags (const guint8 * data, gsize data_len, RsvgHandleFlags flags, GError ** error);
rsvg-base-file-util.c
RsvgHandle * rsvg_handle_new_from_data_with_flags (const guint8 * data, gsize data_len, RsvgHandleFlags flags, GError ** error) { RsvgHandle *handle;
handle = rsvg_handle_new_with_flags (flags);
if (handle) {
if (!rsvg_handle_fill_with_data (handle, data, data_len, error)) {
g_object_unref (handle);
handle = NULL;
}
}
return handle;
}