File: fix_flac_memleaks.patch

package info (click to toggle)
libsndfile 1.0.27-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 6,968 kB
  • ctags: 5,426
  • sloc: ansic: 58,396; sh: 4,551; cpp: 639; makefile: 464; python: 294
file content (44 lines) | stat: -rw-r--r-- 1,446 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
42
43
44
Description: fixing another memory leak in FLAC code
 CVE-2017-8363
Author: Erik de Castro Lopo
Origin: upstream
Applied-Upstream: https://github.com/erikd/libsndfile/commit/cd7da8dbf6ee4310d21d9e44b385d6797160d9e8 & https://github.com/erikd/libsndfile/commit/5206a9b65e61598fde44d276c81b0585bc428562
Last-Update: 2017-05-28
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- libsndfile.orig/src/flac.c
+++ libsndfile/src/flac.c
@@ -430,8 +430,7 @@
 static void
 sf_flac_meta_callback (const FLAC__StreamDecoder * UNUSED (decoder), const FLAC__StreamMetadata *metadata, void *client_data)
 {	SF_PRIVATE *psf = (SF_PRIVATE*) client_data ;
-	FLAC_PRIVATE* pflac = (FLAC_PRIVATE*) psf->codec_data ;
-	int bitwidth = 0, i ;
+	int bitwidth = 0 ;
 
 	switch (metadata->type)
 	{	case FLAC__METADATA_TYPE_STREAMINFO :
@@ -481,12 +480,6 @@
 
 			if (bitwidth > 0)
 				psf_log_printf (psf, "  Bit width   : %d\n", bitwidth) ;
-
-
-			for (i = 0 ; i < psf->sf.channels ; i++)
-				pflac->rbuffer [i] = calloc (FLAC__MAX_BLOCK_SIZE, sizeof (int32_t)) ;
-
-			pflac->wbuffer = (const int32_t* const*) pflac->rbuffer ;
 			break ;
 
 		case FLAC__METADATA_TYPE_VORBIS_COMMENT :
@@ -847,7 +840,9 @@
 
 	psf_log_printf (psf, "End\n") ;
 
-	if (psf->error == 0)
+	if (psf->error != 0)
+		FLAC__stream_decoder_delete (pflac->fsd) ;
+	else
 	{	FLAC__uint64 position ;
 
 		FLAC__stream_decoder_get_decode_position (pflac->fsd, &position) ;