mirror of
https://github.com/talgo-cloud/talgo-libwebp.git
synced 2026-03-07 21:48:16 -08:00
Avoid false pointer deallocation in Go 1.8
See https://github.com/golang/go/issues/19135#issuecomment-280560041
This commit is contained in:
parent
e05d69dcb5
commit
f5dd7f7ed3
1 changed files with 5 additions and 5 deletions
|
|
@ -7,8 +7,8 @@ package webp
|
||||||
|
|
||||||
int writeWebP(uint8_t*, size_t, struct WebPPicture*);
|
int writeWebP(uint8_t*, size_t, struct WebPPicture*);
|
||||||
|
|
||||||
static WebPPicture *malloc_WebPPicture(void) {
|
static WebPPicture *calloc_WebPPicture(void) {
|
||||||
return malloc(sizeof(WebPPicture));
|
return calloc(sizeof(WebPPicture), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void free_WebPPicture(WebPPicture* webpPicture) {
|
static void free_WebPPicture(WebPPicture* webpPicture) {
|
||||||
|
|
@ -445,7 +445,7 @@ func EncodeRGBA(w io.Writer, img image.Image, c *Config) (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
pic := C.malloc_WebPPicture()
|
pic := C.calloc_WebPPicture()
|
||||||
if pic == nil {
|
if pic == nil {
|
||||||
return errors.New("Could not allocate webp picture")
|
return errors.New("Could not allocate webp picture")
|
||||||
}
|
}
|
||||||
|
|
@ -489,7 +489,7 @@ func EncodeGray(w io.Writer, p *image.Gray, c *Config) (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
pic := C.malloc_WebPPicture()
|
pic := C.calloc_WebPPicture()
|
||||||
if pic == nil {
|
if pic == nil {
|
||||||
return errors.New("Could not allocate webp picture")
|
return errors.New("Could not allocate webp picture")
|
||||||
}
|
}
|
||||||
|
|
@ -524,7 +524,7 @@ func EncodeYUVA(w io.Writer, img *YUVAImage, c *Config) (err error) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
pic := C.malloc_WebPPicture()
|
pic := C.calloc_WebPPicture()
|
||||||
if pic == nil {
|
if pic == nil {
|
||||||
return errors.New("Could not allocate webp picture")
|
return errors.New("Could not allocate webp picture")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue