[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r99461: * charset.c (load_charset_map
From: |
Chong Yidong |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r99461: * charset.c (load_charset_map_from_file) |
Date: |
Sat, 06 Feb 2010 08:23:33 -0500 |
User-agent: |
Bazaar (2.0.2) |
------------------------------------------------------------
revno: 99461
committer: Chong Yidong <address@hidden>
branch nick: trunk
timestamp: Sat 2010-02-06 08:23:33 -0500
message:
* charset.c (load_charset_map_from_file)
(load_charset_map_from_vector): Fix last change to use SAFE_ALLOCA
instead of xmalloc (Bug#5526).
modified:
src/ChangeLog
src/charset.c
=== modified file 'src/ChangeLog'
--- a/src/ChangeLog 2010-02-05 03:54:49 +0000
+++ b/src/ChangeLog 2010-02-06 13:23:33 +0000
@@ -1,3 +1,9 @@
+2010-02-06 Chong Yidong <address@hidden>
+
+ * charset.c (load_charset_map_from_file)
+ (load_charset_map_from_vector): Fix last change to use SAFE_ALLOCA
+ instead of xmalloc (Bug#5526).
+
2010-02-05 Chong Yidong <address@hidden>
* charset.c (load_charset_map_from_file): Allocate large
=== modified file 'src/charset.c'
--- a/src/charset.c 2010-02-05 03:54:49 +0000
+++ b/src/charset.c 2010-02-06 13:23:33 +0000
@@ -512,12 +512,13 @@
int eof;
Lisp_Object suffixes;
struct charset_map_entries *head, *entries;
- int n_entries;
- int count = SPECPDL_INDEX ();
+ int n_entries, count;
+ USE_SAFE_ALLOCA;
suffixes = Fcons (build_string (".map"),
Fcons (build_string (".TXT"), Qnil));
+ count = SPECPDL_INDEX ();
specbind (Qfile_name_handler_alist, Qnil);
fd = openp (Vcharset_map_path, mapfile, suffixes, NULL, Qnil);
unbind_to (count, Qnil);
@@ -525,8 +526,12 @@
|| ! (fp = fdopen (fd, "r")))
error ("Failure in loading charset map: %S", SDATA (mapfile));
- head = entries = ((struct charset_map_entries *)
- xmalloc (sizeof (struct charset_map_entries)));
+ /* Use SAFE_ALLOCA instead of alloca, as `charset_map_entries' is
+ large (larger than MAX_ALLOCA). */
+ SAFE_ALLOCA (head, struct charset_map_entries *,
+ sizeof (struct charset_map_entries));
+ entries = head;
+
n_entries = 0;
eof = 0;
while (1)
@@ -549,8 +554,8 @@
if (n_entries > 0 && (n_entries % 0x10000) == 0)
{
- entries->next = ((struct charset_map_entries *)
- alloca (sizeof (struct charset_map_entries)));
+ SAFE_ALLOCA (entries->next, struct charset_map_entries *,
+ sizeof (struct charset_map_entries));
entries = entries->next;
}
idx = n_entries % 0x10000;
@@ -563,7 +568,7 @@
close (fd);
load_charset_map (charset, head, n_entries, control_flag);
- xfree (head);
+ SAFE_FREE ();
}
static void
@@ -578,6 +583,7 @@
int n_entries;
int len = ASIZE (vec);
int i;
+ USE_SAFE_ALLOCA;
if (len % 2 == 1)
{
@@ -585,8 +591,12 @@
return;
}
- head = entries = ((struct charset_map_entries *)
- alloca (sizeof (struct charset_map_entries)));
+ /* Use SAFE_ALLOCA instead of alloca, as `charset_map_entries' is
+ large (larger than MAX_ALLOCA). */
+ SAFE_ALLOCA (head, struct charset_map_entries *,
+ sizeof (struct charset_map_entries));
+ entries = head;
+
n_entries = 0;
for (i = 0; i < len; i += 2)
{
@@ -619,8 +629,8 @@
if (n_entries > 0 && (n_entries % 0x10000) == 0)
{
- entries->next = ((struct charset_map_entries *)
- alloca (sizeof (struct charset_map_entries)));
+ SAFE_ALLOCA (entries->next, struct charset_map_entries *,
+ sizeof (struct charset_map_entries));
entries = entries->next;
}
idx = n_entries % 0x10000;
@@ -631,6 +641,7 @@
}
load_charset_map (charset, head, n_entries, control_flag);
+ SAFE_FREE ();
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r99461: * charset.c (load_charset_map_from_file),
Chong Yidong <=