[SCM] Vim packaging branch, maint/lenny, updated. debian/7.1.314-3-51-g209709e
James Vega
jamessan at debian.org
Sun Oct 12 06:29:01 UTC 2008
The following commit has been merged in the maint/lenny branch:
commit 6336fd7e733cf637d4788594d668b77560607d53
Author: James Vega <jamessan at debian.org>
Date: Wed Oct 8 23:36:45 2008 -0400
Stop reading when EOF is reached to avoid allocing lots of memory.
Signed-off-by: James Vega <jamessan at debian.org>
diff --git a/src/spell.c b/src/spell.c
index f1fb671..a508216 100644
--- a/src/spell.c
+++ b/src/spell.c
@@ -2945,7 +2945,7 @@ read_cnt_string(fd, cnt_bytes, cntp)
/*
* Read a string of length "cnt" from "fd" into allocated memory.
- * Returns NULL when out of memory.
+ * Returns NULL when out of memory or unable to read that many bytes.
*/
static char_u *
read_string(fd, cnt)
@@ -2954,16 +2954,23 @@ read_string(fd, cnt)
{
char_u *str;
int i;
+ int c;
/* allocate memory */
str = alloc((unsigned)cnt + 1);
if (str != NULL)
{
- /* Read the string. Check for truncated files. This will prevent us
- * from using all the memory we're allocated if it isn't necessary --
- * important for COW memory access such as in Linux. */
- for (i = 0; i < cnt && !feof(fd); ++i)
- str[i] = getc(fd);
+ /* Read the string. Quit when running into the EOF. */
+ for (i = 0; i < cnt; ++i)
+ {
+ c = getc(fd);
+ if (c == EOF)
+ {
+ vim_free(str);
+ return NULL;
+ }
+ str[i] = c;
+ }
str[i] = NUL;
}
/* Realloc to how much memory we actually used if we didn't need all the
@@ -3298,6 +3305,7 @@ read_words_section(fd, lp, len)
{
int done = 0;
int i;
+ int c;
char_u word[MAXWLEN];
while (done < len)
@@ -3305,7 +3313,10 @@ read_words_section(fd, lp, len)
/* Read one word at a time. */
for (i = 0; ; ++i)
{
- word[i] = getc(fd);
+ c = getc(fd);
+ if (c == EOF)
+ return SP_TRUNCERROR;
+ word[i] = c;
if (word[i] == NUL)
break;
if (i == MAXWLEN - 1)
@@ -3552,6 +3563,11 @@ read_compound(fd, slang, len)
while (todo-- > 0)
{
c = getc(fd); /* <compflags> */
+ if (c == EOF)
+ {
+ vim_free(pat);
+ return SP_TRUNCERROR;
+ }
/* Add all flags to "sl_compallflags". */
if (vim_strchr((char_u *)"+*[]/", c) == NULL
--
Vim packaging
More information about the pkg-vim-maintainers
mailing list