From 86c171a9ae9be042adfbdde7c4b903dab848d819 Mon Sep 17 00:00:00 2001 From: "wtc%google.com" Date: Fri, 15 Jan 2010 02:05:52 +0000 Subject: [PATCH] Bug 538940: the error message buffer should be one byte larger than the length returned by PR_GetErrorTextLength so that there is room for the terminating null byte. Ensure the buffer is null-terminated when the error text length is 0 because PR_GetErrorText does not copy anything to the buffer in that case. The patch is contributed by Mike Hommey . r=wtc. git-svn-id: svn://10.0.0.236/trunk@259405 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/nsprpub/pr/tests/dlltest.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mozilla/nsprpub/pr/tests/dlltest.c b/mozilla/nsprpub/pr/tests/dlltest.c index f8a5f53b8b2..82a2db5bb0a 100644 --- a/mozilla/nsprpub/pr/tests/dlltest.c +++ b/mozilla/nsprpub/pr/tests/dlltest.c @@ -98,7 +98,8 @@ int main(int argc, char** argv) PR_FreeLibraryName(libName); if (lib == NULL) { PRInt32 textLength = PR_GetErrorTextLength(); - char *text = (char*)PR_MALLOC(textLength); + char *text = (char*)PR_MALLOC(textLength + 1); + text[0] = '\0'; (void)PR_GetErrorText(text); fprintf( stderr, "PR_LoadLibrary failed (%d, %d, %s)\n",