summaryrefslogtreecommitdiff
path: root/src/cairo-output-stream.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2007-10-04 00:38:12 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2007-10-04 00:42:30 +0100
commit8ad56b308ae8bbecfe9873c21551a6d4b2302420 (patch)
treea9c8791e8c30f70fc24a1b1ade069e54c23d98be /src/cairo-output-stream.c
parent66664596559c55913fb0b9c8784fe8ab862c217b (diff)
downloadcairo-8ad56b308ae8bbecfe9873c21551a6d4b2302420.tar.gz
[malloc/error] Add call to _cairo_error() after a failed malloc.
Blitz all allocations to ensure that they raise a _cairo_error(CAIRO_STATUS_NO_MEMORY) on failure.
Diffstat (limited to 'src/cairo-output-stream.c')
-rw-r--r--src/cairo-output-stream.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/cairo-output-stream.c b/src/cairo-output-stream.c
index b9f0d383a..a0add6d7d 100644
--- a/src/cairo-output-stream.c
+++ b/src/cairo-output-stream.c
@@ -119,8 +119,10 @@ _cairo_output_stream_create (cairo_write_func_t write_func,
cairo_output_stream_with_closure_t *stream;
stream = malloc (sizeof (cairo_output_stream_with_closure_t));
- if (stream == NULL)
+ if (stream == NULL) {
+ _cairo_error (CAIRO_STATUS_NO_MEMORY);
return (cairo_output_stream_t *) &_cairo_output_stream_nil;
+ }
_cairo_output_stream_init (&stream->base, closure_write, closure_close);
stream->write_func = write_func;
@@ -468,12 +470,16 @@ _cairo_output_stream_create_for_file (FILE *file)
{
stdio_stream_t *stream;
- if (file == NULL)
+ if (file == NULL) {
+ _cairo_error (CAIRO_STATUS_WRITE_ERROR);
return (cairo_output_stream_t *) &_cairo_output_stream_nil_write_error;
+ }
stream = malloc (sizeof *stream);
- if (stream == NULL)
+ if (stream == NULL) {
+ _cairo_error (CAIRO_STATUS_NO_MEMORY);
return (cairo_output_stream_t *) &_cairo_output_stream_nil;
+ }
_cairo_output_stream_init (&stream->base, stdio_write, stdio_flush);
stream->file = file;
@@ -488,12 +494,15 @@ _cairo_output_stream_create_for_filename (const char *filename)
FILE *file;
file = fopen (filename, "wb");
- if (file == NULL)
+ if (file == NULL) {
+ _cairo_error (CAIRO_STATUS_WRITE_ERROR);
return (cairo_output_stream_t *) &_cairo_output_stream_nil_write_error;
+ }
stream = malloc (sizeof *stream);
if (stream == NULL) {
fclose (file);
+ _cairo_error (CAIRO_STATUS_NO_MEMORY);
return (cairo_output_stream_t *) &_cairo_output_stream_nil;
}
@@ -534,8 +543,10 @@ _cairo_memory_stream_create (void)
memory_stream_t *stream;
stream = malloc (sizeof *stream);
- if (stream == NULL)
+ if (stream == NULL) {
+ _cairo_error (CAIRO_STATUS_NO_MEMORY);
return (cairo_output_stream_t *) &_cairo_output_stream_nil;
+ }
_cairo_output_stream_init (&stream->base, memory_write, memory_close);
_cairo_array_init (&stream->array, 1);