From e39473e4fb516b62f56221063b255138e7ba86af Mon Sep 17 00:00:00 2001 From: Hans-Joerg Schurr Date: Sat, 5 Jun 2021 22:48:38 +0200 Subject: [PATCH] Return error if the pointer for a return value is NULL --- src/hvif-light.c | 6 ++++++ src/hvif-light.h | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/hvif-light.c b/src/hvif-light.c index 2ab3ac2..998730c 100644 --- a/src/hvif-light.c +++ b/src/hvif-light.c @@ -799,6 +799,7 @@ hvif_status hvif_style_gradient_type( hvif_image* image, uint8_t style, hvif_gradients_type* type) { + if (type == NULL) return ERROR_NULL_OUT; if (image == NULL) return ERROR_STYLE; if (style >= image->num_styles) return ERROR_STYLE; *type = image->styles[style].gradient_type; @@ -808,6 +809,7 @@ hvif_style_gradient_type( hvif_status hvif_style_num_stops(hvif_image* image, uint8_t style, uint8_t* num_stops) { + if (num_stops == NULL) return ERROR_NULL_OUT; if (image == NULL) return ERROR_STYLE; if (style >= image->num_styles) return ERROR_STYLE; *num_stops = image->styles[style].num_stops; @@ -819,6 +821,7 @@ hvif_style_stop( hvif_image* image, uint8_t style, uint8_t stop, hvif_gradient_stop* gradient_stop) { + if (gradient_stop == NULL) return ERROR_NULL_OUT; if (image == NULL) return ERROR_STYLE; if (style >= image->num_styles) return ERROR_STYLE; if (stop >= image->styles[style].num_stops) return ERROR_STYLE; @@ -831,6 +834,7 @@ hvif_status hvif_style_transformation( hvif_image* image, uint8_t style, hvif_matrix* transformation) { + if (transformation == NULL) return ERROR_NULL_OUT; if (image == NULL) return ERROR_STYLE; if (style >= image->num_styles) return ERROR_STYLE; *transformation = image->styles[style].transformation; @@ -839,6 +843,7 @@ hvif_style_transformation( hvif_status hvif_path_num_points( hvif_image* image, uint8_t path, uint8_t* points) { + if (points == NULL) return ERROR_NULL_OUT; if (image == NULL) return ERROR_PATH; if (path >= image->num_paths) return ERROR_PATH; *points = image->paths[path].num_points; @@ -847,6 +852,7 @@ hvif_status hvif_path_num_points( hvif_status hvif_path_closed( hvif_image* image, uint8_t path, bool* closed) { + if (closed == NULL) return ERROR_NULL_OUT; if (image == NULL) return ERROR_PATH; if (path >= image->num_paths) return ERROR_PATH; *closed = image->paths[path].closed; diff --git a/src/hvif-light.h b/src/hvif-light.h index 30963b5..843b2a4 100644 --- a/src/hvif-light.h +++ b/src/hvif-light.h @@ -28,7 +28,8 @@ typedef enum hvif_status ERROR_MAGIC, /**< The magic number of the file is wrong. */ ERROR_STYLE, /**< A style related error occurred. */ ERROR_PATH, /**< A path related error occurred. */ - ERROR_SHAPE /**< A shape related error occurred. */ + ERROR_SHAPE, /**< A shape related error occurred. */ + ERROR_NULL_OUT /**< A pointer used for results was NULL. */ } hvif_status; /**