5534: Fix stack overflow caused by too large a pref string. r=mcmullen/a=chofmann

git-svn-id: svn://10.0.0.236/trunk@29802 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
akkana%netscape.com 1999-04-29 20:42:14 +00:00
parent 266e1da5ec
commit 08aa4877d6
2 changed files with 9 additions and 4 deletions

View File

@ -108,7 +108,7 @@ unix/jsbuffer.h: Makefile $(CONFIG_FILES)
@if test ! -d unix; then rm -f unix && mkdir -p unix; fi
@(echo "/* This is an automatically generated file */" > $@; \
echo >> $@; \
echo "static char* pref_init_buffer = " >> $@; \
cat $(CONFIG_FILES) | sed 's/\\/\\\\/g' | sed 's/\\r/\\n/' | sed 's/\"/\\\"/g' | sed 's/^M//g' | sed 's/^/"/' | sed 's/$$/\\n"/' >> $@; \
echo \; >> $@; \
echo "static char* pref_init_buffer[] = {" >> $@; \
cat $(CONFIG_FILES) | sed 's/\\/\\\\/g' | sed 's/\\r/\\n/' | sed 's/\"/\\\"/g' | sed 's/^M//g' | sed 's/^/"/' | sed 's/$$/\\n",/' >> $@; \
echo "0 };" >> $@; \
)

View File

@ -45,10 +45,15 @@ JSBool
pref_InitInitialObjects(void)
{
JSBool status;
int i;
PR_ASSERT(pref_init_buffer);
status = PREF_EvaluateJSBuffer(pref_init_buffer, strlen(pref_init_buffer));
/* loop over all the strings in the init buffer */
for (i=0; i < (sizeof pref_init_buffer / sizeof *pref_init_buffer) && pref_init_buffer[i] != 0; ++i)
{
status = PREF_EvaluateJSBuffer(pref_init_buffer[i], strlen(pref_init_buffer[i]));
}
/* these strings never get freed, but that's probably the way it should be */
PREF_SetDefaultCharPref("browser.cache.directory",