diff --git a/netwerk/cache2/CacheEntry.cpp b/netwerk/cache2/CacheEntry.cpp index 76a1c275a032..53759c00deb5 100644 --- a/netwerk/cache2/CacheEntry.cpp +++ b/netwerk/cache2/CacheEntry.cpp @@ -1052,16 +1052,15 @@ NS_IMETHODIMP CacheEntry::GetSecurityInfo(nsISupports * *aSecurityInfo) NS_ENSURE_SUCCESS(mFileStatus, NS_ERROR_NOT_AVAILABLE); - char const* info; + nsXPIDLCString info; nsCOMPtr secInfo; nsresult rv; - rv = mFile->GetElement("security-info", &info); + rv = mFile->GetElement("security-info", getter_Copies(info)); NS_ENSURE_SUCCESS(rv, rv); if (info) { - rv = NS_DeserializeObject(nsDependentCString(info), - getter_AddRefs(secInfo)); + rv = NS_DeserializeObject(info, getter_AddRefs(secInfo)); NS_ENSURE_SUCCESS(rv, rv); } @@ -1148,15 +1147,7 @@ NS_IMETHODIMP CacheEntry::GetMetaDataElement(const char * aKey, char * *aRetval) { NS_ENSURE_SUCCESS(mFileStatus, NS_ERROR_NOT_AVAILABLE); - const char *value; - nsresult rv = mFile->GetElement(aKey, &value); - NS_ENSURE_SUCCESS(rv, rv); - - if (!value) - return NS_ERROR_NOT_AVAILABLE; - - *aRetval = NS_strdup(value); - return NS_OK; + return mFile->GetElement(aKey, aRetval); } NS_IMETHODIMP CacheEntry::SetMetaDataElement(const char * aKey, const char * aValue) diff --git a/netwerk/cache2/CacheFile.cpp b/netwerk/cache2/CacheFile.cpp index f951cf2ae158..5c2f2e07aaef 100644 --- a/netwerk/cache2/CacheFile.cpp +++ b/netwerk/cache2/CacheFile.cpp @@ -775,13 +775,18 @@ CacheFile::ThrowMemoryCachedData() } nsresult -CacheFile::GetElement(const char *aKey, const char **_retval) +CacheFile::GetElement(const char *aKey, char **_retval) { CacheFileAutoLock lock(this); MOZ_ASSERT(mMetadata); NS_ENSURE_TRUE(mMetadata, NS_ERROR_UNEXPECTED); - *_retval = mMetadata->GetElement(aKey); + const char *value; + value = mMetadata->GetElement(aKey); + if (!value) + return NS_ERROR_NOT_AVAILABLE; + + *_retval = NS_strdup(value); return NS_OK; } diff --git a/netwerk/cache2/CacheFile.h b/netwerk/cache2/CacheFile.h index 75fac399a913..0e6069ee641b 100644 --- a/netwerk/cache2/CacheFile.h +++ b/netwerk/cache2/CacheFile.h @@ -83,7 +83,7 @@ public: nsresult ThrowMemoryCachedData(); // metadata forwarders - nsresult GetElement(const char *aKey, const char **_retval); + nsresult GetElement(const char *aKey, char **_retval); nsresult SetElement(const char *aKey, const char *aValue); nsresult ElementsSize(uint32_t *_retval); nsresult SetExpirationTime(uint32_t aExpirationTime);