[PATCH] [output-stream] Accept a NULL filename

Chris Wilson chris at chris-wilson.co.uk
Wed Oct 15 14:15:17 PDT 2008


Principally to support creating a dummy vector surface (i.e.
cairo_ps_surface_create (NULL, 1, 1)) that can be used to determine font
extents (or target font options) before opening an output file, but also
because we currently fail to do any sanity checking at the entry point.
---
 src/cairo-output-stream.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/cairo-output-stream.c b/src/cairo-output-stream.c
index 7062007..d02b277 100644
--- a/src/cairo-output-stream.c
+++ b/src/cairo-output-stream.c
@@ -583,6 +583,9 @@ _cairo_output_stream_create_for_filename (const char *filename)
     stdio_stream_t *stream;
     FILE *file;
 
+    if (filename == NULL)
+	return _cairo_null_stream_create ();
+
     file = fopen (filename, "wb");
     if (file == NULL) {
 	switch (errno) {
-- 
1.5.6.3


--=-qBgMwfM4jwl8MXBlvCG5
Content-Description: 
Content-Disposition: inline; filename="0002--output-stream-Protect-against-NULL-write_func.patch"
Content-Type: text/x-patch; charset="UTF-8"
Content-Transfer-Encoding: 7bit



More information about the cairo mailing list