Skip to content

Commit

Permalink
Check plum_buffer arguments passed to plum_load_image for null po…
Browse files Browse the repository at this point in the history
…inters
  • Loading branch information
aaaaaa123456789 committed Jan 30, 2022
1 parent 6183bea commit 223b896
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Note: releases are listed from latest to oldest.
- Added safeguards to prevent internal `longjmp` misuse when generating image files
- Ensured that the `PLUM_FILENAME`, `PLUM_BUFFER` and `PLUM_CALLBACK` constants are always `size_t` as documented
- Enforced the size limitation on the value returned by a callback when using the `PLUM_CALLBACK` loading/storing mode
- Added a validation for `PLUM_BUFFER` arguments to `plum_load_image`, ensuring that the buffer's `data` member isn't
a null pointer
- Handled out-of-palette background colors when generating a GIF file, ensuring that they would never cause the
process to fail (the background is ignored instead if there are no available palette slots)
- Added some warning flags for debug builds, and cleared some warnings that would be raised by them
Expand Down
3 changes: 2 additions & 1 deletion docs/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ The error constants signal the following reasons for failure:
- `PLUM_OK` (zero): success.
This value will be used only if the function succeeds, i.e., it returns a non-`NULL` value.
- `PLUM_ERR_INVALID_ARGUMENTS`: `buffer` is `NULL`.
- `PLUM_ERR_INVALID_ARGUMENTS`: `buffer` is `NULL`, or `size` is [`PLUM_BUFFER`][mode-constants] and `buffer` points
to a [`struct plum_buffer`][buffer] whose `data` member is `NULL`.
- `PLUM_ERR_INVALID_FILE_FORMAT`: the image's file format wasn't recognized, or the image was damaged or couldn't be
loaded for some reason.
This indicates an error in the image data, such as an unexpected value.
Expand Down
1 change: 1 addition & 0 deletions src/load.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ void prepare_image_buffer_data (struct context * context, const void * restrict
case PLUM_BUFFER:
context -> data = ((const struct plum_buffer *) buffer) -> data;
context -> size = ((const struct plum_buffer *) buffer) -> size;
if (!context -> data) throw(context, PLUM_ERR_INVALID_ARGUMENTS);
return;
case PLUM_CALLBACK:
load_from_callback(context, buffer);
Expand Down

0 comments on commit 223b896

Please sign in to comment.