mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-13 14:34:33 +02:00
add ABI compatibility check
minor revision shouldn't matter, we only check major revision number. Bumped all version numbers so that incompatibility starts *now* Change-Id: Id06c20f03039845ae4cfb3fd121807b931d67ee4
This commit is contained in:
@ -631,7 +631,7 @@ WebPDemuxer* WebPDemuxInternal(const WebPData* data, int allow_partial,
|
||||
MemBuffer mem;
|
||||
WebPDemuxer* dmux;
|
||||
|
||||
if (version != WEBP_DEMUX_ABI_VERSION) return NULL;
|
||||
if (WEBP_ABI_IS_INCOMPATIBLE(version, WEBP_DEMUX_ABI_VERSION)) return NULL;
|
||||
if (data == NULL || data->bytes_ == NULL || data->size_ == 0) return NULL;
|
||||
|
||||
if (!InitMemBuffer(&mem, data->bytes_, data->size_)) return NULL;
|
||||
|
@ -35,11 +35,14 @@ static void MuxInit(WebPMux* const mux) {
|
||||
}
|
||||
|
||||
WebPMux* WebPNewInternal(int version) {
|
||||
WebPMux* const mux = (version == WEBP_MUX_ABI_VERSION) ?
|
||||
(WebPMux*)malloc(sizeof(WebPMux)) : NULL;
|
||||
// If mux is NULL MuxInit is a noop.
|
||||
MuxInit(mux);
|
||||
return mux;
|
||||
if (WEBP_ABI_IS_INCOMPATIBLE(version, WEBP_MUX_ABI_VERSION)) {
|
||||
return NULL;
|
||||
} else {
|
||||
WebPMux* const mux = (WebPMux*)malloc(sizeof(WebPMux));
|
||||
// If mux is NULL MuxInit is a noop.
|
||||
MuxInit(mux);
|
||||
return mux;
|
||||
}
|
||||
}
|
||||
|
||||
static void DeleteAllChunks(WebPChunk** const chunk_list) {
|
||||
|
@ -89,7 +89,9 @@ WebPMux* WebPMuxCreateInternal(const WebPData* bitstream, int copy_data,
|
||||
ChunkInit(&chunk);
|
||||
|
||||
// Sanity checks.
|
||||
if (version != WEBP_MUX_ABI_VERSION) return NULL; // version mismatch
|
||||
if (WEBP_ABI_IS_INCOMPATIBLE(version, WEBP_MUX_ABI_VERSION)) {
|
||||
return NULL; // version mismatch
|
||||
}
|
||||
if (bitstream == NULL) return NULL;
|
||||
|
||||
data = bitstream->bytes_;
|
||||
|
Reference in New Issue
Block a user