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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
* A memory leak in decode-coding-region and similar routines has been fixed.
Patch: coding-region-leak.diff
Author: Kenichi Handa and Florian Weimer
Status: has been incorporated upstream
Date: Fri, 8 Oct 2004 23:13:59 +0200
A long-standing memory leak in decode-coding-region and similar
routines has been fixed.
diff -urNad /home/fw/debian/tmp/emacs21-21.3+1/src/callproc.c emacs21-21.3+1/src/callproc.c
--- /home/fw/debian/tmp/emacs21-21.3+1/src/callproc.c 2002-07-09 02:02:36.000000000 +0200
+++ emacs21-21.3+1/src/callproc.c 2004-09-30 09:44:42.000000000 +0200
@@ -790,6 +790,8 @@
{
detect_coding (&process_coding, bufptr, nread);
if (process_coding.composing != COMPOSITION_DISABLED)
+ /* We have not yet allocated the composition
+ data because the coding type was undecided. */
coding_allocate_composition_data (&process_coding, PT);
}
if (process_coding.cmp_data)
diff -urNad /home/fw/debian/tmp/emacs21-21.3+1/src/coding.c emacs21-21.3+1/src/coding.c
--- /home/fw/debian/tmp/emacs21-21.3+1/src/coding.c 2003-03-16 23:06:55.000000000 +0100
+++ emacs21-21.3+1/src/coding.c 2004-09-30 09:44:42.000000000 +0200
@@ -5489,8 +5489,11 @@
coding_allocate_composition_data (coding, from);
}
- /* Try to skip the heading and tailing ASCIIs. */
- if (coding->type != coding_type_ccl)
+ /* Try to skip the heading and tailing ASCIIs. We can't skip them
+ if we must run CCL program or there are compositions to
+ encode. */
+ if (coding->type != coding_type_ccl
+ && (! coding->cmp_data || coding->cmp_data->used == 0))
{
int from_byte_orig = from_byte, to_byte_orig = to_byte;
@@ -5506,6 +5509,7 @@
if (!replace)
/* We must record and adjust for this new text now. */
adjust_after_insert (from, from_byte_orig, to, to_byte_orig, len);
+ coding_free_composition_data (coding);
return 0;
}
@@ -6106,12 +6110,16 @@
coding_save_composition (coding, from, to, str);
/* Try to skip the heading and tailing ASCIIs. */
- if (coding->type != coding_type_ccl)
+ if (coding->type != coding_type_ccl
+ && (! coding->cmp_data || coding->cmp_data->used == 0))
{
SHRINK_CONVERSION_REGION (&from, &to_byte, coding, XSTRING (str)->data,
1);
if (from == to_byte)
- return (nocopy ? str : Fcopy_sequence (str));
+ {
+ coding_free_composition_data (coding);
+ return (nocopy ? str : Fcopy_sequence (str));
+ }
shrinked_bytes = from + (STRING_BYTES (XSTRING (str)) - to_byte);
}
diff -urNad /home/fw/debian/tmp/emacs21-21.3+1/src/fileio.c emacs21-21.3+1/src/fileio.c
--- /home/fw/debian/tmp/emacs21-21.3+1/src/fileio.c 2003-02-04 11:52:40.000000000 +0100
+++ emacs21-21.3+1/src/fileio.c 2004-09-30 09:44:42.000000000 +0200
@@ -4087,7 +4087,7 @@
if (how_much < 0)
{
xfree (conversion_buffer);
-
+ coding_free_composition_data (&coding);
if (how_much == -1)
error ("IO error reading %s: %s",
XSTRING (orig_filename)->data, emacs_strerror (errno));
@@ -4109,6 +4109,7 @@
if (bufpos == inserted)
{
xfree (conversion_buffer);
+ coding_free_composition_data (&coding);
emacs_close (fd);
specpdl_ptr--;
/* Truncate the buffer to the size of the file. */
diff -urNad /home/fw/debian/tmp/emacs21-21.3+1/src/process.c emacs21-21.3+1/src/process.c
--- /home/fw/debian/tmp/emacs21-21.3+1/src/process.c 2003-03-16 23:06:56.000000000 +0100
+++ emacs21-21.3+1/src/process.c 2004-09-30 09:44:42.000000000 +0200
@@ -3347,6 +3347,7 @@
object = XPROCESS (proc)->encoding_buf;
encode_coding (coding, (char *) buf, XSTRING (object)->data,
len, STRING_BYTES (XSTRING (object)));
+ coding_free_composition_data (coding);
len = coding->produced;
buf = XSTRING (object)->data;
if (temp_buf)
|