File: 0007-fix-memory-leak.patch

package info (click to toggle)
libsixel 1.5.2-2%2Bdeb9u1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 13,684 kB
  • sloc: ansic: 20,253; sh: 4,273; cpp: 1,227; makefile: 402; python: 306; xml: 271; ruby: 31; perl: 26
file content (41 lines) | stat: -rw-r--r-- 1,143 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
From: Takatsugu Nokubi <takatsugu.nokubi@robotfund.co.jp>
Date: Mon, 9 Sep 2019 15:27:38 +0900
Subject: fix memory leak

---
 src/decoder.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/decoder.c b/src/decoder.c
index e3fbd0d..908e115 100644
--- a/src/decoder.c
+++ b/src/decoder.c
@@ -224,15 +224,15 @@ sixel_decoder_decode(
     sixel_decoder_t /* in */ *decoder)
 {
     SIXELSTATUS status = SIXEL_FALSE;
-    unsigned char *raw_data;
+    unsigned char *raw_data = NULL;
     int sx;
     int sy;
     int raw_len;
     int max;
     int n;
     FILE *input_fp = NULL;
-    unsigned char *indexed_pixels;
-    unsigned char *palette;
+    unsigned char *indexed_pixels = NULL;
+    unsigned char *palette = NULL;
     int ncolors;
     unsigned char *pixels = NULL;
 
@@ -320,6 +320,9 @@ sixel_decoder_decode(
 
 end:
     sixel_allocator_free(decoder->allocator, pixels);
+    sixel_allocator_free(decoder->allocator, raw_data);
+    sixel_allocator_free(decoder->allocator, indexed_pixels);
+    sixel_allocator_free(decoder->allocator, palette);
     sixel_decoder_ref(decoder);
 
     return status;