Fixed compile time errors + minor memory allocation problems.

This commit is contained in:
rogerl%netscape.com 1999-07-15 23:37:05 +00:00
Родитель fd9b6eadb4
Коммит 7d5915b747
1 изменённых файлов: 5 добавлений и 4 удалений

Просмотреть файл

@ -20,6 +20,7 @@
* JS standard exception implementation. * JS standard exception implementation.
*/ */
#include <string.h>
#include "jsstddef.h" #include "jsstddef.h"
#include "jstypes.h" #include "jstypes.h"
#include "jsutil.h" /* Added by JSIFY */ #include "jsutil.h" /* Added by JSIFY */
@ -104,10 +105,10 @@ exn_initPrivate(JSContext *cx, JSErrorReport *report)
report->uclinebuf); report->uclinebuf);
} else } else
newReport->uclinebuf = newReport->uctokenptr = NULL; newReport->uclinebuf = newReport->uctokenptr = NULL;
if (report->ucmessage != NULL) { if (report->ucmessage != NULL) {
jsint len = js_strlen(report->ucmessage) + 1; jsint len = js_strlen(report->ucmessage) + 1;
newReport->ucmessage = (const jschar *)JS_malloc(cx, len); newReport->ucmessage = (const jschar *)JS_malloc(cx, len * sizeof(jschar));
js_strncpy((jschar *)newReport->ucmessage, report->ucmessage, len); js_strncpy((jschar *)newReport->ucmessage, report->ucmessage, len);
if (report->messageArgs) { if (report->messageArgs) {
@ -125,9 +126,9 @@ exn_initPrivate(JSContext *cx, JSErrorReport *report)
js_strncpy((jschar *)(newReport->messageArgs[i]), js_strncpy((jschar *)(newReport->messageArgs[i]),
report->messageArgs[i], len); report->messageArgs[i], len);
} }
report->messageArgs[i] = NULL; newReport->messageArgs[i] = NULL;
} else { } else {
report->messageArgs = NULL; newReport->messageArgs = NULL;
} }
} else { } else {
newReport->ucmessage = NULL; newReport->ucmessage = NULL;