зеркало из https://github.com/mozilla/gecko-dev.git
fix bug 16753, memory leak, r=rjc
This commit is contained in:
Родитель
eaeac236aa
Коммит
e6b45e35c1
|
@ -343,10 +343,10 @@ cookie_Put(nsOutputFileStream strm, const nsString& aLine)
|
||||||
* strip carriage returns and line feeds from end of line
|
* strip carriage returns and line feeds from end of line
|
||||||
*/
|
*/
|
||||||
PRInt32
|
PRInt32
|
||||||
cookie_GetLine(nsInputFileStream strm, nsAutoString*& aLine) {
|
cookie_GetLine(nsInputFileStream strm, nsAutoString& aLine) {
|
||||||
|
|
||||||
/* read the line */
|
/* read the line */
|
||||||
aLine = new nsAutoString("");
|
aLine.Truncate();
|
||||||
char c;
|
char c;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
c = strm.get();
|
c = strm.get();
|
||||||
|
@ -359,7 +359,7 @@ cookie_GetLine(nsInputFileStream strm, nsAutoString*& aLine) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (c != '\r') {
|
if (c != '\r') {
|
||||||
*aLine += c;
|
aLine += c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1749,7 +1749,7 @@ cookie_SavePermissions() {
|
||||||
/* reads the HTTP cookies permission from disk */
|
/* reads the HTTP cookies permission from disk */
|
||||||
PRIVATE void
|
PRIVATE void
|
||||||
cookie_LoadPermissions() {
|
cookie_LoadPermissions() {
|
||||||
nsAutoString * buffer;
|
nsAutoString buffer;
|
||||||
cookie_PermissionStruct * new_cookie_permission;
|
cookie_PermissionStruct * new_cookie_permission;
|
||||||
nsFileSpec dirSpec;
|
nsFileSpec dirSpec;
|
||||||
nsresult rv = cookie_ProfileDirectory(dirSpec);
|
nsresult rv = cookie_ProfileDirectory(dirSpec);
|
||||||
|
@ -1768,31 +1768,28 @@ cookie_LoadPermissions() {
|
||||||
*/
|
*/
|
||||||
cookie_LockPermissionList();
|
cookie_LockPermissionList();
|
||||||
while(cookie_GetLine(strm,buffer) != -1) {
|
while(cookie_GetLine(strm,buffer) != -1) {
|
||||||
if (buffer->CharAt(0) == '#' || buffer->CharAt(0) == CR ||
|
if (buffer.CharAt(0) == '#' || buffer.CharAt(0) == CR ||
|
||||||
buffer->CharAt(0) == LF || buffer->CharAt(0) == 0) {
|
buffer.CharAt(0) == LF || buffer.CharAt(0) == 0) {
|
||||||
delete buffer;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int hostIndex, permissionIndex;
|
int hostIndex, permissionIndex;
|
||||||
hostIndex = 0;
|
hostIndex = 0;
|
||||||
if ((permissionIndex=buffer->FindChar('\t', PR_FALSE,hostIndex)+1) == 0) {
|
if ((permissionIndex=buffer.FindChar('\t', PR_FALSE,hostIndex)+1) == 0) {
|
||||||
delete buffer;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ignore leading periods in host name */
|
/* ignore leading periods in host name */
|
||||||
while (hostIndex < permissionIndex && (buffer->CharAt(hostIndex) == '.')) {
|
while (hostIndex < permissionIndex && (buffer.CharAt(hostIndex) == '.')) {
|
||||||
hostIndex++;
|
hostIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsString host, permission;
|
nsString host, permission;
|
||||||
buffer->Mid(host, hostIndex, permissionIndex-hostIndex-1);
|
buffer.Mid(host, hostIndex, permissionIndex-hostIndex-1);
|
||||||
buffer->Mid(permission, permissionIndex, buffer->Length()-permissionIndex);
|
buffer.Mid(permission, permissionIndex, buffer.Length()-permissionIndex);
|
||||||
|
|
||||||
/* create a new cookie_struct and fill it in */
|
/* create a new cookie_struct and fill it in */
|
||||||
new_cookie_permission = PR_NEW(cookie_PermissionStruct);
|
new_cookie_permission = PR_NEW(cookie_PermissionStruct);
|
||||||
if (!new_cookie_permission) {
|
if (!new_cookie_permission) {
|
||||||
delete buffer;
|
|
||||||
cookie_UnlockPermissionListst();
|
cookie_UnlockPermissionListst();
|
||||||
strm.close();
|
strm.close();
|
||||||
return;
|
return;
|
||||||
|
@ -1804,7 +1801,6 @@ cookie_LoadPermissions() {
|
||||||
} else {
|
} else {
|
||||||
new_cookie_permission->permission = PR_FALSE;
|
new_cookie_permission->permission = PR_FALSE;
|
||||||
}
|
}
|
||||||
delete buffer;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* a host value of "@@@@" is a special code designating the
|
* a host value of "@@@@" is a special code designating the
|
||||||
|
@ -1911,7 +1907,7 @@ PRIVATE void
|
||||||
cookie_LoadCookies() {
|
cookie_LoadCookies() {
|
||||||
cookie_CookieStruct *new_cookie, *tmp_cookie_ptr;
|
cookie_CookieStruct *new_cookie, *tmp_cookie_ptr;
|
||||||
size_t new_len;
|
size_t new_len;
|
||||||
nsAutoString * buffer;
|
nsAutoString buffer;
|
||||||
PRBool added_to_list;
|
PRBool added_to_list;
|
||||||
nsFileSpec dirSpec;
|
nsFileSpec dirSpec;
|
||||||
nsresult rv = cookie_ProfileDirectory(dirSpec);
|
nsresult rv = cookie_ProfileDirectory(dirSpec);
|
||||||
|
@ -1937,35 +1933,32 @@ cookie_LoadCookies() {
|
||||||
*/
|
*/
|
||||||
while (cookie_GetLine(strm,buffer) != -1){
|
while (cookie_GetLine(strm,buffer) != -1){
|
||||||
added_to_list = PR_FALSE;
|
added_to_list = PR_FALSE;
|
||||||
if (buffer->CharAt(0) == '#' || buffer->CharAt(0) == CR ||
|
if (buffer.CharAt(0) == '#' || buffer.CharAt(0) == CR ||
|
||||||
buffer->CharAt(0) == LF || buffer->CharAt(0) == 0) {
|
buffer.CharAt(0) == LF || buffer.CharAt(0) == 0) {
|
||||||
delete buffer;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int hostIndex, isDomainIndex, pathIndex, xxxIndex, expiresIndex, nameIndex, cookieIndex;
|
int hostIndex, isDomainIndex, pathIndex, xxxIndex, expiresIndex, nameIndex, cookieIndex;
|
||||||
hostIndex = 0;
|
hostIndex = 0;
|
||||||
if ((isDomainIndex=buffer->FindChar('\t', PR_FALSE,hostIndex)+1) == 0 ||
|
if ((isDomainIndex=buffer.FindChar('\t', PR_FALSE,hostIndex)+1) == 0 ||
|
||||||
(pathIndex=buffer->FindChar('\t', PR_FALSE,isDomainIndex)+1) == 0 ||
|
(pathIndex=buffer.FindChar('\t', PR_FALSE,isDomainIndex)+1) == 0 ||
|
||||||
(xxxIndex=buffer->FindChar('\t', PR_FALSE,pathIndex)+1) == 0 ||
|
(xxxIndex=buffer.FindChar('\t', PR_FALSE,pathIndex)+1) == 0 ||
|
||||||
(expiresIndex=buffer->FindChar('\t', PR_FALSE,xxxIndex)+1) == 0 ||
|
(expiresIndex=buffer.FindChar('\t', PR_FALSE,xxxIndex)+1) == 0 ||
|
||||||
(nameIndex=buffer->FindChar('\t', PR_FALSE,expiresIndex)+1) == 0 ||
|
(nameIndex=buffer.FindChar('\t', PR_FALSE,expiresIndex)+1) == 0 ||
|
||||||
(cookieIndex=buffer->FindChar('\t', PR_FALSE,nameIndex)+1) == 0 ) {
|
(cookieIndex=buffer.FindChar('\t', PR_FALSE,nameIndex)+1) == 0 ) {
|
||||||
delete buffer;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
nsAutoString host, isDomain, path, xxx, expires, name, cookie;
|
nsAutoString host, isDomain, path, xxx, expires, name, cookie;
|
||||||
buffer->Mid(host, hostIndex, isDomainIndex-hostIndex-1);
|
buffer.Mid(host, hostIndex, isDomainIndex-hostIndex-1);
|
||||||
buffer->Mid(isDomain, isDomainIndex, pathIndex-isDomainIndex-1);
|
buffer.Mid(isDomain, isDomainIndex, pathIndex-isDomainIndex-1);
|
||||||
buffer->Mid(path, pathIndex, xxxIndex-pathIndex-1);
|
buffer.Mid(path, pathIndex, xxxIndex-pathIndex-1);
|
||||||
buffer->Mid(xxx, xxxIndex, expiresIndex-xxxIndex-1);
|
buffer.Mid(xxx, xxxIndex, expiresIndex-xxxIndex-1);
|
||||||
buffer->Mid(expires, expiresIndex, nameIndex-expiresIndex-1);
|
buffer.Mid(expires, expiresIndex, nameIndex-expiresIndex-1);
|
||||||
buffer->Mid(name, nameIndex, cookieIndex-nameIndex-1);
|
buffer.Mid(name, nameIndex, cookieIndex-nameIndex-1);
|
||||||
buffer->Mid(cookie, cookieIndex, buffer->Length()-cookieIndex);
|
buffer.Mid(cookie, cookieIndex, buffer.Length()-cookieIndex);
|
||||||
|
|
||||||
/* create a new cookie_struct and fill it in */
|
/* create a new cookie_struct and fill it in */
|
||||||
new_cookie = PR_NEW(cookie_CookieStruct);
|
new_cookie = PR_NEW(cookie_CookieStruct);
|
||||||
if (!new_cookie) {
|
if (!new_cookie) {
|
||||||
delete buffer;
|
|
||||||
cookie_UnlockCookieList();
|
cookie_UnlockCookieList();
|
||||||
strm.close();
|
strm.close();
|
||||||
return;
|
return;
|
||||||
|
@ -1988,7 +1981,6 @@ cookie_LoadCookies() {
|
||||||
char * expiresCString = expires.ToNewCString();
|
char * expiresCString = expires.ToNewCString();
|
||||||
new_cookie->expires = atol(expiresCString);
|
new_cookie->expires = atol(expiresCString);
|
||||||
nsCRT::free(expiresCString);
|
nsCRT::free(expiresCString);
|
||||||
delete buffer;
|
|
||||||
|
|
||||||
/* start new cookie list if one does not already exist */
|
/* start new cookie list if one does not already exist */
|
||||||
if (!cookie_cookieList) {
|
if (!cookie_cookieList) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче