mirror of
				https://github.com/webmproject/libwebp.git
				synced 2025-10-31 02:15:42 +01:00 
			
		
		
		
	fix missing free()
Change-Id: Ia09869321e00bb3fb8e92e5d91993ff583dc6cdf
This commit is contained in:
		| @@ -311,7 +311,7 @@ void WebPInitCustomIo(VP8Io* const io) { | ||||
| } | ||||
|  | ||||
| //----------------------------------------------------------------------------- | ||||
| // Init/Check decoding parameters | ||||
| // Init/Check/Free decoding parameters and buffer | ||||
|  | ||||
| int WebPInitDecParams(const uint8_t* data, uint32_t data_size, int* width, | ||||
|                       int* height, WebPDecParams* const params) { | ||||
| @@ -376,6 +376,11 @@ int WebPCheckDecParams(const VP8Io* io, const WebPDecParams* params, | ||||
|   return ok; | ||||
| } | ||||
|  | ||||
| void WebPClearDecParams(WebPDecParams* params) { | ||||
|   free(params->output); | ||||
|   memset(params, 0, sizeof(*params)); | ||||
| } | ||||
|  | ||||
| //----------------------------------------------------------------------------- | ||||
| // "Into" variants | ||||
|  | ||||
| @@ -510,11 +515,14 @@ static uint8_t* Decode(WEBP_CSP_MODE mode, const uint8_t* data, | ||||
|   if (!WebPInitDecParams(data, data_size, width, height, ¶ms)) { | ||||
|     return NULL; | ||||
|   } | ||||
|   if (params_out) *params_out = params; | ||||
|  | ||||
|   size = params.stride * (*height); | ||||
|   uv_size = params.u_stride * ((*height + 1) / 2); | ||||
|   return DecodeInto(mode, data, data_size, ¶ms, size, uv_size, uv_size); | ||||
|   if (!DecodeInto(mode, data, data_size, ¶ms, size, uv_size, uv_size)) { | ||||
|     WebPClearDecParams(¶ms); | ||||
|   } | ||||
|   if (params_out) *params_out = params; | ||||
|   return params.output; | ||||
| } | ||||
|  | ||||
| uint8_t* WebPDecodeRGB(const uint8_t* data, uint32_t data_size, | ||||
|   | ||||
| @@ -52,6 +52,10 @@ int WebPInitDecParams(const uint8_t* data, uint32_t data_size, int* width, | ||||
| int WebPCheckDecParams(const VP8Io* io, const WebPDecParams* params, | ||||
|                        int output_size, int output_u_size, int output_v_size); | ||||
|  | ||||
| // Deallocate memory allocated by WebPInitDecParams() and reset the | ||||
| // WebPDecParams object. | ||||
| void WebPClearDecParams(WebPDecParams* params); | ||||
|  | ||||
| #if defined(__cplusplus) || defined(c_plusplus) | ||||
| }    // extern "C" | ||||
| #endif | ||||
|   | ||||
		Reference in New Issue
	
	Block a user