if (!STRINGP (lcss))
{
/* Generate the CSS for the SVG image. */
- const char *css_spec = "svg{font-family:\"%s\";font-size:%4dpx}";
- int css_len = strlen (css_spec) + strlen (img->face_font_family);
+ /* FIXME: The below calculations leave enough space for a font
+ size up to 9999, if it overflows we just throw an error but
+ should probably increase the buffer size. */
+ const char *css_spec = "svg{font-family:\"%s\";font-size:%dpx}";
+ int css_len = strlen (css_spec) + strlen (img->face_font_family) + 1;
css = xmalloc (css_len);
- snprintf (css, css_len, css_spec, img->face_font_family, img->face_font_size);
+ if (css_len <= snprintf (css, css_len, css_spec,
+ img->face_font_family, img->face_font_size))
+ goto rsvg_error;
+
rsvg_handle_set_stylesheet (rsvg_handle, (guint8 *)css, strlen (css), NULL);
}
else
wrapped_contents = xmalloc (buffer_size);
- if (!wrapped_contents
- || buffer_size <= snprintf (wrapped_contents, buffer_size, wrapper,
- foreground & 0xFFFFFF, width, height,
- viewbox_width, viewbox_height,
- background & 0xFFFFFF,
- SSDATA (encoded_contents)))
+ if (buffer_size <= snprintf (wrapped_contents, buffer_size, wrapper,
+ foreground & 0xFFFFFF, width, height,
+ viewbox_width, viewbox_height,
+ background & 0xFFFFFF,
+ SSDATA (encoded_contents)))
goto rsvg_error;
wrapped_size = strlen (wrapped_contents);