mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-09 09:38:11 +02:00
[cairo-font-options] Use cairo_font_options_status() rather open-coding.
By switching to cairo_font_options_status() instead of checking against the _cairo_font_options_nil error object, the API is protected from NULL dereferences.
This commit is contained in:
parent
b15e91d2b6
commit
02d0e07063
1 changed files with 8 additions and 8 deletions
|
|
@ -52,7 +52,7 @@ static const cairo_font_options_t _cairo_font_options_nil = {
|
|||
void
|
||||
_cairo_font_options_init_default (cairo_font_options_t *options)
|
||||
{
|
||||
if (options == (cairo_font_options_t *)&_cairo_font_options_nil)
|
||||
if (cairo_font_options_status (options))
|
||||
return;
|
||||
|
||||
options->antialias = CAIRO_ANTIALIAS_DEFAULT;
|
||||
|
|
@ -118,7 +118,7 @@ cairo_font_options_copy (const cairo_font_options_t *original)
|
|||
{
|
||||
cairo_font_options_t *options;
|
||||
|
||||
if (original == &_cairo_font_options_nil)
|
||||
if (cairo_font_options_status ((cairo_font_options_t *) original))
|
||||
return (cairo_font_options_t *)&_cairo_font_options_nil;
|
||||
|
||||
options = malloc (sizeof (cairo_font_options_t));
|
||||
|
|
@ -142,7 +142,7 @@ cairo_font_options_copy (const cairo_font_options_t *original)
|
|||
void
|
||||
cairo_font_options_destroy (cairo_font_options_t *options)
|
||||
{
|
||||
if (options == (cairo_font_options_t *)&_cairo_font_options_nil)
|
||||
if (cairo_font_options_status (options))
|
||||
return;
|
||||
|
||||
free (options);
|
||||
|
|
@ -184,7 +184,7 @@ void
|
|||
cairo_font_options_merge (cairo_font_options_t *options,
|
||||
const cairo_font_options_t *other)
|
||||
{
|
||||
if (options == (cairo_font_options_t *)&_cairo_font_options_nil)
|
||||
if (cairo_font_options_status (options))
|
||||
return;
|
||||
|
||||
if (other->antialias != CAIRO_ANTIALIAS_DEFAULT)
|
||||
|
|
@ -252,7 +252,7 @@ void
|
|||
cairo_font_options_set_antialias (cairo_font_options_t *options,
|
||||
cairo_antialias_t antialias)
|
||||
{
|
||||
if (options == (cairo_font_options_t *)&_cairo_font_options_nil)
|
||||
if (cairo_font_options_status (options))
|
||||
return;
|
||||
|
||||
options->antialias = antialias;
|
||||
|
|
@ -288,7 +288,7 @@ void
|
|||
cairo_font_options_set_subpixel_order (cairo_font_options_t *options,
|
||||
cairo_subpixel_order_t subpixel_order)
|
||||
{
|
||||
if (options == (cairo_font_options_t *)&_cairo_font_options_nil)
|
||||
if (cairo_font_options_status (options))
|
||||
return;
|
||||
|
||||
options->subpixel_order = subpixel_order;
|
||||
|
|
@ -324,7 +324,7 @@ void
|
|||
cairo_font_options_set_hint_style (cairo_font_options_t *options,
|
||||
cairo_hint_style_t hint_style)
|
||||
{
|
||||
if (options == (cairo_font_options_t *)&_cairo_font_options_nil)
|
||||
if (cairo_font_options_status (options))
|
||||
return;
|
||||
|
||||
options->hint_style = hint_style;
|
||||
|
|
@ -360,7 +360,7 @@ void
|
|||
cairo_font_options_set_hint_metrics (cairo_font_options_t *options,
|
||||
cairo_hint_metrics_t hint_metrics)
|
||||
{
|
||||
if (options == (cairo_font_options_t *)&_cairo_font_options_nil)
|
||||
if (cairo_font_options_status (options))
|
||||
return;
|
||||
|
||||
options->hint_metrics = hint_metrics;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue