Bugzilla Bug 298953: fixed a memory leak in sslBuffer_Grow if PORT_Realloc

fails. r=nelsonb.
This commit is contained in:
wtchang%redhat.com 2005-06-28 17:48:26 +00:00
Родитель 2b9dd7c45d
Коммит fafa59ce5f
1 изменённых файлов: 6 добавлений и 4 удалений

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

@ -37,7 +37,7 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* $Id: sslsecur.c,v 1.29 2005/04/06 21:35:45 nelsonb%netscape.com Exp $ */
/* $Id: sslsecur.c,v 1.30 2005/06/28 17:48:26 wtchang%redhat.com Exp $ */
#include "cert.h"
#include "secitem.h"
#include "keyhi.h"
@ -389,16 +389,18 @@ SECStatus
sslBuffer_Grow(sslBuffer *b, unsigned int newLen)
{
if (newLen > b->space) {
unsigned char *newBuf;
if (b->buf) {
b->buf = (unsigned char *) PORT_Realloc(b->buf, newLen);
newBuf = (unsigned char *) PORT_Realloc(b->buf, newLen);
} else {
b->buf = (unsigned char *) PORT_Alloc(newLen);
newBuf = (unsigned char *) PORT_Alloc(newLen);
}
if (!b->buf) {
if (!newBuf) {
return SECFailure;
}
SSL_TRC(10, ("%d: SSL: grow buffer from %d to %d",
SSL_GETPID(), b->space, newLen));
b->buf = newBuf;
b->space = newLen;
}
return SECSuccess;