Skip to content

Commit

Permalink
GUACAMOLE-1875: Merge check return values of WebP API functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
necouchman authored Nov 7, 2023
2 parents f339b48 + c60f40c commit 88ece72
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/libguac/encode-webp.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,22 @@ int guac_webp_write(guac_socket* socket, guac_stream* stream,
config.method = 2; /* Compression method (0=fast/larger, 6=slow/smaller) */

/* Validate configuration */
WebPValidateConfig(&config);
if (!WebPValidateConfig(&config)) {
return -1;
}

/* Set up WebP picture */
WebPPictureInit(&picture);
if (!WebPPictureInit(&picture)) {
return -1;
}
picture.use_argb = 1;
picture.width = width;
picture.height = height;

/* Allocate and init writer */
WebPPictureAlloc(&picture);
if (!WebPPictureAlloc(&picture)) {
return -1;
}
picture.writer = guac_webp_stream_write;
picture.custom_ptr = &writer;
guac_webp_stream_writer_init(&writer, socket, stream);
Expand Down Expand Up @@ -244,15 +250,15 @@ int guac_webp_write(guac_socket* socket, guac_stream* stream,
}

/* Encode image */
WebPEncode(&config, &picture);
const int result = WebPEncode(&config, &picture) ? 0 : -1;

/* Free picture */
WebPPictureFree(&picture);

/* Ensure all data is written */
guac_webp_flush_data(&writer);

return 0;
return result;

}

0 comments on commit 88ece72

Please sign in to comment.