From 6b1992aefa3ebe9f48edd182e66d58fdb204d109 Mon Sep 17 00:00:00 2001 From: "brendan%mozilla.org" Date: Mon, 27 Oct 2003 19:13:01 +0000 Subject: [PATCH] Don't under-malloc for short script filename entry (223810, r=shaver, a=dbaron). --- js/src/jsscript.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/js/src/jsscript.c b/js/src/jsscript.c index 11c3ebdbe50..d932f6539e5 100644 --- a/js/src/jsscript.c +++ b/js/src/jsscript.c @@ -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)