Return error if the pointer for a return value is NULL
This commit is contained in:
parent
1ec380ae54
commit
e39473e4fb
|
@ -799,6 +799,7 @@ hvif_status
|
||||||
hvif_style_gradient_type(
|
hvif_style_gradient_type(
|
||||||
hvif_image* image, uint8_t style, hvif_gradients_type* 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 (image == NULL) return ERROR_STYLE;
|
||||||
if (style >= image->num_styles) return ERROR_STYLE;
|
if (style >= image->num_styles) return ERROR_STYLE;
|
||||||
*type = image->styles[style].gradient_type;
|
*type = image->styles[style].gradient_type;
|
||||||
|
@ -808,6 +809,7 @@ hvif_style_gradient_type(
|
||||||
hvif_status
|
hvif_status
|
||||||
hvif_style_num_stops(hvif_image* image, uint8_t style, uint8_t* num_stops)
|
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 (image == NULL) return ERROR_STYLE;
|
||||||
if (style >= image->num_styles) return ERROR_STYLE;
|
if (style >= image->num_styles) return ERROR_STYLE;
|
||||||
*num_stops = image->styles[style].num_stops;
|
*num_stops = image->styles[style].num_stops;
|
||||||
|
@ -819,6 +821,7 @@ hvif_style_stop(
|
||||||
hvif_image* image, uint8_t style, uint8_t stop,
|
hvif_image* image, uint8_t style, uint8_t stop,
|
||||||
hvif_gradient_stop* gradient_stop)
|
hvif_gradient_stop* gradient_stop)
|
||||||
{
|
{
|
||||||
|
if (gradient_stop == NULL) return ERROR_NULL_OUT;
|
||||||
if (image == NULL) return ERROR_STYLE;
|
if (image == NULL) return ERROR_STYLE;
|
||||||
if (style >= image->num_styles) return ERROR_STYLE;
|
if (style >= image->num_styles) return ERROR_STYLE;
|
||||||
if (stop >= image->styles[style].num_stops) return ERROR_STYLE;
|
if (stop >= image->styles[style].num_stops) return ERROR_STYLE;
|
||||||
|
@ -831,6 +834,7 @@ hvif_status
|
||||||
hvif_style_transformation(
|
hvif_style_transformation(
|
||||||
hvif_image* image, uint8_t style, hvif_matrix* transformation)
|
hvif_image* image, uint8_t style, hvif_matrix* transformation)
|
||||||
{
|
{
|
||||||
|
if (transformation == NULL) return ERROR_NULL_OUT;
|
||||||
if (image == NULL) return ERROR_STYLE;
|
if (image == NULL) return ERROR_STYLE;
|
||||||
if (style >= image->num_styles) return ERROR_STYLE;
|
if (style >= image->num_styles) return ERROR_STYLE;
|
||||||
*transformation = image->styles[style].transformation;
|
*transformation = image->styles[style].transformation;
|
||||||
|
@ -839,6 +843,7 @@ hvif_style_transformation(
|
||||||
|
|
||||||
hvif_status hvif_path_num_points(
|
hvif_status hvif_path_num_points(
|
||||||
hvif_image* image, uint8_t path, uint8_t* points) {
|
hvif_image* image, uint8_t path, uint8_t* points) {
|
||||||
|
if (points == NULL) return ERROR_NULL_OUT;
|
||||||
if (image == NULL) return ERROR_PATH;
|
if (image == NULL) return ERROR_PATH;
|
||||||
if (path >= image->num_paths) return ERROR_PATH;
|
if (path >= image->num_paths) return ERROR_PATH;
|
||||||
*points = image->paths[path].num_points;
|
*points = image->paths[path].num_points;
|
||||||
|
@ -847,6 +852,7 @@ hvif_status hvif_path_num_points(
|
||||||
|
|
||||||
hvif_status hvif_path_closed(
|
hvif_status hvif_path_closed(
|
||||||
hvif_image* image, uint8_t path, bool* closed) {
|
hvif_image* image, uint8_t path, bool* closed) {
|
||||||
|
if (closed == NULL) return ERROR_NULL_OUT;
|
||||||
if (image == NULL) return ERROR_PATH;
|
if (image == NULL) return ERROR_PATH;
|
||||||
if (path >= image->num_paths) return ERROR_PATH;
|
if (path >= image->num_paths) return ERROR_PATH;
|
||||||
*closed = image->paths[path].closed;
|
*closed = image->paths[path].closed;
|
||||||
|
|
|
@ -28,7 +28,8 @@ typedef enum hvif_status
|
||||||
ERROR_MAGIC, /**< The magic number of the file is wrong. */
|
ERROR_MAGIC, /**< The magic number of the file is wrong. */
|
||||||
ERROR_STYLE, /**< A style related error occurred. */
|
ERROR_STYLE, /**< A style related error occurred. */
|
||||||
ERROR_PATH, /**< A path 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;
|
} hvif_status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue