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
<mh+mozilla@glandium.org>.  r=wtc.


git-svn-id: svn://10.0.0.236/trunk@259405 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
wtc%google.com
2010-01-15 02:05:52 +00:00
parent 9cbdff6813
commit 86c171a9ae

View File

@@ -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",