Don't under-malloc for short script filename entry (223810, r=shaver, a=dbaron).

This commit is contained in:
brendan%mozilla.org 2003-10-27 19:13:01 +00:00
parent 7514a2a682
commit 102afcc93c

View File

@ -859,8 +859,9 @@ typedef struct ScriptFilenameEntry {
JS_STATIC_DLL_CALLBACK(JSHashEntry *)
js_alloc_entry(void *priv, const void *key)
{
return (JSHashEntry *)
malloc(offsetof(ScriptFilenameEntry, filename) + strlen(key) + 1);
size_t nbytes = offsetof(ScriptFilenameEntry, filename) + strlen(key) + 1;
return (JSHashEntry *) malloc(JS_MAX(nbytes, sizeof(JSHashEntry)));
}
JS_STATIC_DLL_CALLBACK(void)