From 135e8b1942e1e9e226422ea37f6c72db9e26674f Mon Sep 17 00:00:00 2001 From: James Zern Date: Thu, 16 Feb 2012 17:41:29 -0800 Subject: [PATCH] WebPMuxGetImage: allow image param to be NULL but not both alpha & image Change-Id: I6822a740de7577eedcbe7529382aa2c020d1e8e4 --- src/mux/muxread.c | 13 ++++++++----- src/webp/mux.h | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/mux/muxread.c b/src/mux/muxread.c index 1cefbc69..9c605840 100644 --- a/src/mux/muxread.c +++ b/src/mux/muxread.c @@ -230,8 +230,8 @@ WebPMuxError WebPMuxGetImage(const WebPMux* const mux, WebPMuxError err; WebPMuxImage* wpi = NULL; - if (mux == NULL || image == NULL) return WEBP_MUX_INVALID_ARGUMENT; - memset(image, 0, sizeof(*image)); + if (mux == NULL || (image == NULL && alpha == NULL)) + return WEBP_MUX_INVALID_ARGUMENT; err = ValidateForImage(mux); if (err != WEBP_MUX_OK) return err; @@ -250,9 +250,12 @@ WebPMuxError WebPMuxGetImage(const WebPMux* const mux, } // Get image chunk. - if (wpi->vp8_ != NULL) { - image->bytes_ = wpi->vp8_->data_; - image->size_ = wpi->vp8_->payload_size_; + if (image != NULL) { + memset(image, 0, sizeof(*image)); + if (wpi->vp8_ != NULL) { + image->bytes_ = wpi->vp8_->data_; + image->size_ = wpi->vp8_->payload_size_; + } } return WEBP_MUX_OK; } diff --git a/src/webp/mux.h b/src/webp/mux.h index e74c1479..138f54db 100644 --- a/src/webp/mux.h +++ b/src/webp/mux.h @@ -148,8 +148,8 @@ WEBP_EXTERN(WebPMuxError) WebPMuxSetImage(WebPMux* const mux, // image - (out) the image data // alpha - (out) the alpha data of the image (if present) // Returns: -// WEBP_MUX_INVALID_ARGUMENT - if either mux or image is NULL -// OR if mux contains animation/tiling. +// WEBP_MUX_INVALID_ARGUMENT - if either mux or both image & alpha are NULL +// OR mux contains animation/tiling. // WEBP_MUX_NOT_FOUND - if image is not present in mux object. // WEBP_MUX_OK - on success. WEBP_EXTERN(WebPMuxError) WebPMuxGetImage(const WebPMux* const mux,