зеркало из https://github.com/mozilla/gecko-dev.git
General memory repairs (leakage, freeing mismatched mem, umrs)
This commit is contained in:
Родитель
78027b8dcd
Коммит
235357382b
|
@ -926,8 +926,10 @@ net_start_first_connect(const char *host,
|
|||
* The user is guaranteing it's existence and usability. */
|
||||
if ( localIP > 0 ) {
|
||||
PRStatus status;
|
||||
PRNetAddr *addr = (PRNetAddr *)PR_Malloc(sizeof(PRNetAddr));
|
||||
PRErrorCode errorCode; /* see http://www.mozilla.org/docs/refList/refNSPR/prerr.htm#1027954 */
|
||||
PRNetAddr *addr = (PRNetAddr *)PR_Malloc(sizeof(PRNetAddr));
|
||||
if (!addr)
|
||||
return MK_UNABLE_TO_CONNECT;
|
||||
status = PR_InitializeNetAddr(PR_IpAddrNull, 0, addr);
|
||||
if (status != PR_SUCCESS) {
|
||||
errorCode = PR_GetError();
|
||||
|
@ -938,6 +940,7 @@ net_start_first_connect(const char *host,
|
|||
errorCode = PR_GetError();
|
||||
}
|
||||
}
|
||||
PR_Free(addr);
|
||||
}
|
||||
|
||||
/* if it's not equal to PR_SUCCESS something went wrong
|
||||
|
@ -1454,8 +1457,10 @@ NET_FinishConnect (CONST char *url,
|
|||
* The user is guaranteing it's existence and usability. */
|
||||
if ( localIP > 0 ) {
|
||||
PRStatus status;
|
||||
PRNetAddr *addr = (PRNetAddr *)PR_Malloc(sizeof(PRNetAddr));
|
||||
PRErrorCode errorCode; /* see http://www.mozilla.org/docs/refList/refNSPR/prerr.htm#1027954 */
|
||||
PRNetAddr *addr = (PRNetAddr *)PR_Malloc(sizeof(PRNetAddr));
|
||||
if (!addr)
|
||||
return MK_UNABLE_TO_CONNECT;
|
||||
status = PR_InitializeNetAddr(PR_IpAddrNull, 0, addr);
|
||||
if (status != PR_SUCCESS) {
|
||||
errorCode = PR_GetError();
|
||||
|
@ -1466,6 +1471,7 @@ NET_FinishConnect (CONST char *url,
|
|||
errorCode = PR_GetError();
|
||||
}
|
||||
}
|
||||
PR_Free(addr);
|
||||
}
|
||||
|
||||
if(PR_SUCCESS != PR_Connect (*sock,
|
||||
|
|
|
@ -207,12 +207,14 @@ void nsNetFile::GenerateGlobalRandomBytes(void *aDest, size_t aLen) {
|
|||
#define MAX_PATH_LEN 512
|
||||
|
||||
nsresult nsNetFile::GetCacheFileName(char *aDirTok, char **aRes) {
|
||||
char file_buf[MAX_PATH_LEN];
|
||||
char *file_buf = nsnull;
|
||||
char *ext = ".MOZ";
|
||||
char *prefix = "M";
|
||||
PRStatus status;
|
||||
PRFileInfo statinfo;
|
||||
char *dir = (char*)PL_HashTableLookup(mHTDirs, aDirTok);
|
||||
|
||||
file_buf = (char*)PR_Calloc(1, MAX_PATH_LEN);
|
||||
if (!dir)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
|
|
|
@ -924,6 +924,7 @@ WH_FileName (const char *NetName, XP_FileType type)
|
|||
}
|
||||
|
||||
rv = fileMgr->GetFilePath( (aName ? aName : NetName), &path);
|
||||
PR_FREEIF(aName);
|
||||
if (rv != NS_OK)
|
||||
return NULL;
|
||||
|
||||
|
@ -949,10 +950,11 @@ WH_TempName(XP_FileType type, const char * prefix)
|
|||
}
|
||||
|
||||
rv = fileMgr->GetCacheFileName(aName, &path);
|
||||
PR_FREEIF(aName);
|
||||
if (rv != NS_OK)
|
||||
return NULL;
|
||||
|
||||
return PL_strdup(path);
|
||||
return path;
|
||||
}
|
||||
|
||||
PUBLIC int
|
||||
|
@ -1050,8 +1052,9 @@ NET_I_XP_FileOpen(const char * name, XP_FileType type, const XP_FilePerm perm)
|
|||
/* call OpenFile with nsNetFile syntax if necesary. */
|
||||
if ( (!name || !*name)
|
||||
|| type == xpCache ) {
|
||||
nsString newName;
|
||||
newName = xpFileTypeToName(type);
|
||||
char *tmpName = xpFileTypeToName(type);
|
||||
nsString newName = tmpName;
|
||||
PR_FREEIF(tmpName)
|
||||
if (newName.Length() < 1) {
|
||||
PR_Free(trans);
|
||||
PR_Free(xpFp);
|
||||
|
@ -1062,7 +1065,8 @@ NET_I_XP_FileOpen(const char * name, XP_FileType type, const XP_FilePerm perm)
|
|||
}
|
||||
|
||||
rv = fileMgr->OpenFile( (aName ? aName : name), mode, &nsFp);
|
||||
PR_Free(aName);
|
||||
if (aName)
|
||||
delete aName;
|
||||
if (NS_OK != rv) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1180,8 +1184,9 @@ NET_I_XP_FileRemove(const char * name, XP_FileType type)
|
|||
|
||||
if ( (!name || !*name)
|
||||
|| type == xpCache ) {
|
||||
nsString newName;
|
||||
newName = xpFileTypeToName(type);
|
||||
char *tmpName = xpFileTypeToName(type);
|
||||
nsString newName = tmpName;
|
||||
PR_FREEIF(tmpName);
|
||||
if (newName.Length() < 1) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1196,6 +1201,8 @@ NET_I_XP_FileRemove(const char * name, XP_FileType type)
|
|||
}
|
||||
|
||||
rv = fileMgr->FileRemove((aName ? aName : name));
|
||||
if (aName)
|
||||
delete aName;
|
||||
if (rv != NS_OK)
|
||||
return -1;
|
||||
|
||||
|
@ -1208,17 +1215,18 @@ NET_I_XP_Stat(const char * name, XP_StatStruct * info, XP_FileType type)
|
|||
int result = -1;
|
||||
PRFileInfo fileInfo;
|
||||
PRStatus status;
|
||||
char *newName;
|
||||
char *newName, *tmpName;
|
||||
nsString ourName;
|
||||
char *path;
|
||||
nsresult rv;
|
||||
|
||||
switch (type) {
|
||||
case xpCache:
|
||||
ourName = xpFileTypeToName(type);
|
||||
if (ourName.Length() < 1) {
|
||||
tmpName = xpFileTypeToName(type);
|
||||
if (!tmpName)
|
||||
return NULL;
|
||||
}
|
||||
ourName = tmpName;
|
||||
PR_FREEIF(tmpName);
|
||||
ourName.Append(name);
|
||||
newName = ourName.ToNewCString();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче