fix potential memory trounce when syncing for offline on some imap servers, r=ducarroz, sr=sspitzer 181372

This commit is contained in:
bienvenu%netscape.com 2002-12-10 23:43:09 +00:00
parent 9928f2e24e
commit 2aa2f6fa6e

View File

@ -398,21 +398,12 @@ NS_IMETHODIMP nsImapFlagAndUidState::GetCustomFlags(PRUint32 uid, char **customF
nsAutoCMonitor(this);
if (m_customFlagsHash)
{
nsPRUint32Key hashKey(uid);
char *value = (char *) m_customFlagsHash->Get(&hashKey);
nsPRUint32Key hashKey(uid);
char *value = (char *) m_customFlagsHash->Get(&hashKey);
if (value)
{
PRUint32 valueLen = 0, curStringLen = 0;
do
{
curStringLen = strlen(value + valueLen) + 1;
valueLen += curStringLen;
}
while (curStringLen > 1);
*customFlags = (char *) PR_Malloc(valueLen);
memcpy(*customFlags, value, valueLen);
return NS_OK;
*customFlags = nsCRT::strdup(value);
return (*customFlags) ? NS_OK : NS_ERROR_FAILURE;
}
}
*customFlags = nsnull;