[output-stream] Protect against NULL write_func.

Allow the user to specify a NULL write_func for the output stream so that
a dummy surface can be created, for example, for querying target font
options or font extents.

Currently we do not perform any sanity checks at the user entry point and
will generate a mysterious SEGV during cairo_surface_finish() - which may
not immediately be obvious that it is due to a NULL write_func.
This commit is contained in:
Chris Wilson 2008-10-15 22:24:32 +01:00
parent 84e4a825ff
commit 41c8eefc6d

View file

@ -116,6 +116,9 @@ closure_write (cairo_output_stream_t *stream,
cairo_output_stream_with_closure_t *stream_with_closure =
(cairo_output_stream_with_closure_t *) stream;
if (stream_with_closure->write_func == NULL)
return CAIRO_STATUS_SUCCESS;
return stream_with_closure->write_func (stream_with_closure->closure,
data, length);
}