File: memory_bugs.diff

package info (click to toggle)
speech-tools 1%3A2.5.0-14
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 10,040 kB
  • sloc: cpp: 67,350; ansic: 12,174; sh: 4,055; java: 3,748; makefile: 1,106; lisp: 711; perl: 396; awk: 85; xml: 9
file content (51 lines) | stat: -rw-r--r-- 1,325 bytes parent folder | download | duplicates (3)
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
45
46
47
48
49
50
51
Description: Modify data loading memory management to avoid crashes.
This patch fixes a crash in audsp in Festival and other
memory leaks.
Bug: #601294
Author: Samuel Thibault.
Applied-Upstream: https://github.com/festvox/speech_tools/pull/7

--- a/base_class/rateconv.cc
+++ b/base_class/rateconv.cc
@@ -431,7 +431,7 @@ static int outmax;
 
 static int ioerr(void)
 {
-    delete g_coep;
+    delete[] g_coep;
     return -1;
 }
 
@@ -585,7 +585,7 @@ int rateconv(short *in,int isize, short
 	    return ioerr();
     } while (outsize == OUTBUFFSIZE); 
 
-    delete g_coep;
+    delete[] g_coep;
 
     *osize = outpos;
 
--- a/base_class/string/EST_String.cc
+++ b/base_class/string/EST_String.cc
@@ -329,6 +329,7 @@ int EST_String::gsub_internal (const cha
 	  p += length;
 	  at=end;
 	}
+   if (p != from+at)
       memcpy(p, from+at, size-at);
 
       p += size-at;
--- a/speech_class/EST_WaveFile.cc
+++ b/speech_class/EST_WaveFile.cc
@@ -90,7 +90,10 @@ EST_read_status load_using(standard_load
 
   if (status == read_ok)
     {
-      wv.values().set_memory(data, 0, nsamp, nchan, TRUE);
+      short *data2 = new short[nsamp*nchan];
+      memcpy(data2, data, nsamp*nchan*sizeof(short));
+      wfree(data);
+      wv.values().set_memory(data2, 0, nsamp, nchan, TRUE);
       wv.set_sample_rate(srate);
     }