mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-12 22:14:29 +02:00
fix memory leak in SDL_Init()
we use a static guard to only call SDL_Init() once. Another option would be to call SDL_Quit(), but it doesn't seem to be doing anything. Also, fix the HTML code and add 'use strict' directive. BUG=webp:354 Change-Id: I3c6421e2c1c8cc200556cd4092a0ead9a8b054ef
This commit is contained in:
@ -28,6 +28,7 @@
|
||||
#include <SDL/SDL.h>
|
||||
#endif
|
||||
|
||||
static int init_ok = 0;
|
||||
int WebpToSDL(const char* data, unsigned int data_size) {
|
||||
int ok = 0;
|
||||
VP8StatusCode status;
|
||||
@ -42,7 +43,10 @@ int WebpToSDL(const char* data, unsigned int data_size) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
if (!init_ok) {
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
init_ok = 1;
|
||||
}
|
||||
|
||||
status = WebPGetFeatures((uint8_t*)data, (size_t)data_size, &config.input);
|
||||
if (status != VP8_STATUS_OK) goto Error;
|
||||
@ -97,6 +101,7 @@ int WebpToSDL(const char* data, unsigned int data_size) {
|
||||
Error:
|
||||
SDL_FreeSurface(surface);
|
||||
SDL_FreeSurface(screen);
|
||||
WebPFreeDecBuffer(output);
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user