Skip to content

Commit

Permalink
Better error checking
Browse files Browse the repository at this point in the history
  • Loading branch information
dukesook committed May 31, 2024
1 parent bdd6380 commit b2fa352
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions libheif/heif.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2708,17 +2708,21 @@ struct heif_error heif_context_encode_image(struct heif_context* ctx,


struct heif_error heif_context_encode_grid(struct heif_context* ctx,
struct heif_image** tiles, // array of tile images
struct heif_image** tiles,
uint16_t columns,
uint16_t rows,
struct heif_encoder* encoder,
const struct heif_encoding_options* input_options,
struct heif_image_handle** out_image_handle)
{
if (!encoder) {
if (!encoder || !tiles) {
return Error(heif_error_Usage_error,
heif_suberror_Null_pointer_argument).error_struct(ctx->context.get());
}
else if (rows == 0 || columns == 0) {
return Error(heif_error_Usage_error,
heif_suberror_Invalid_parameter_value).error_struct(ctx->context.get());
}

// TODO: Don't repeat this code from heif_context_encode_image()
heif_encoding_options options;
Expand Down
2 changes: 1 addition & 1 deletion libheif/heif.h
Original file line number Diff line number Diff line change
Expand Up @@ -2047,7 +2047,7 @@ struct heif_error heif_context_encode_image(struct heif_context*,
* @param encoder Defines the encoder to use. See heif_context_get_encoder_for_format()
* @param input_options Optional, may be nullptr.
* @param out_image_handle Returns a handle to the grid. The caller is responsible for freeing it.
* @return struct heif_error
* @return Returns an error if ctx, tiles, or encoder is nullptr. If rows or columns is 0.
*/
LIBHEIF_API
struct heif_error heif_context_encode_grid(struct heif_context* ctx,
Expand Down

0 comments on commit b2fa352

Please sign in to comment.