summaryrefslogtreecommitdiff
path: root/content
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2010-09-16 19:33:18 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2010-09-16 19:33:18 +0000
commitdb736f83782261ad34b74a9cea4ef6f7f81d8fed (patch)
tree96d315be6fcdc920229384995bdd7459a37e32f9 /content
parentdafccf21d5b40923429ede5296e85cb6e8791d64 (diff)
downloadnetsurf-db736f83782261ad34b74a9cea4ef6f7f81d8fed.tar.gz
netsurf-db736f83782261ad34b74a9cea4ef6f7f81d8fed.tar.bz2
Fix heap corruption
svn path=/trunk/netsurf/; revision=10786
Diffstat (limited to 'content')
-rw-r--r--content/llcache.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/content/llcache.c b/content/llcache.c
index de0c56b8f..37fd31e3c 100644
--- a/content/llcache.c
+++ b/content/llcache.c
@@ -158,7 +158,7 @@ static nserror llcache_object_retrieve_from_cache(const char *url,
llcache_object **result);
static bool llcache_object_is_fresh(const llcache_object *object);
static nserror llcache_object_cache_update(llcache_object *object);
-static nserror llcache_object_clone_cache_data(const llcache_object *source,
+static nserror llcache_object_clone_cache_data(llcache_object *source,
llcache_object *destination, bool deep);
static nserror llcache_object_fetch(llcache_object *object, uint32_t flags,
const char *referer, const llcache_post_data *post,
@@ -845,8 +845,10 @@ nserror llcache_object_cache_update(llcache_object *object)
* \param destination Destination object to clone cache data into
* \param deep Whether to deep-copy the data or not
* \return NSERROR_OK on success, appropriate error otherwise
+ *
+ * \post If \a deep is false, then any pointers in \a source will be set to NULL
*/
-nserror llcache_object_clone_cache_data(const llcache_object *source,
+nserror llcache_object_clone_cache_data(llcache_object *source,
llcache_object *destination, bool deep)
{
/* ETag must be first, as it can fail when deep cloning */
@@ -858,6 +860,9 @@ nserror llcache_object_clone_cache_data(const llcache_object *source,
etag = strdup(source->cache.etag);
if (etag == NULL)
return NSERROR_NOMEM;
+ } else {
+ /* Destination takes ownership */
+ source->cache.etag = NULL;
}
if (destination->cache.etag != NULL)