summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2009-07-30 14:43:05 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2009-07-30 14:43:05 +0000
commit173e9c15667d8eaaf3b777bd929172d782efef24 (patch)
tree4e32352e29917dda86e0607946dc6387cba49501
parent551c4e5bc7147f8eee1bb48cdd26bc83a66aa78a (diff)
downloadlibcss-173e9c15667d8eaaf3b777bd929172d782efef24.tar.gz
libcss-173e9c15667d8eaaf3b777bd929172d782efef24.tar.bz2
Plug potential memory leaks in property setting
svn path=/trunk/libcss/; revision=8911
-rw-r--r--include/libcss/computed.h2
-rw-r--r--src/select/propset.h27
2 files changed, 29 insertions, 0 deletions
diff --git a/include/libcss/computed.h b/include/libcss/computed.h
index 04f30fe..722c967 100644
--- a/include/libcss/computed.h
+++ b/include/libcss/computed.h
@@ -97,6 +97,8 @@ typedef struct css_computed_uncommon {
* --- ---
* 5 bits sizeof(ptr) bytes
*
+ * Encode content as an array of content items, terminated with a blank entry.
+ *
* content 2 sizeof(ptr)
* --- ---
* 2 bits sizeof(ptr)
diff --git a/src/select/propset.h b/src/select/propset.h
index c98d47b..ac860fd 100644
--- a/src/select/propset.h
+++ b/src/select/propset.h
@@ -183,6 +183,11 @@ static inline css_error set_counter_increment(
*bits = (*bits & ~COUNTER_INCREMENT_MASK) |
((type & 0x1) << COUNTER_INCREMENT_SHIFT);
+ /* Free existing array */
+ if (style->uncommon->counter_increment != NULL &&
+ style->uncommon->counter_increment != counters)
+ style->alloc(style->uncommon->counter_increment, 0, style->pw);
+
style->uncommon->counter_increment = counters;
return CSS_OK;
@@ -208,6 +213,11 @@ static inline css_error set_counter_reset(
*bits = (*bits & ~COUNTER_RESET_MASK) |
((type & 0x1) << COUNTER_RESET_SHIFT);
+ /* Free existing array */
+ if (style->uncommon->counter_reset != NULL &&
+ style->uncommon->counter_reset != counters)
+ style->alloc(style->uncommon->counter_reset, 0, style->pw);
+
style->uncommon->counter_reset = counters;
return CSS_OK;
@@ -233,6 +243,10 @@ static inline css_error set_cursor(
*bits = (*bits & ~CURSOR_MASK) |
((type & 0x1f) << CURSOR_SHIFT);
+ /* Free existing array */
+ if (style->uncommon->cursor != NULL && style->uncommon->cursor != urls)
+ style->alloc(style->uncommon->cursor, 0, style->pw);
+
style->uncommon->cursor = urls;
return CSS_OK;
@@ -317,6 +331,11 @@ static inline css_error set_content(
*bits = (*bits & ~CONTENT_MASK) |
((type & 0x3) << CONTENT_SHIFT);
+ /* Free existing array */
+ if (style->uncommon->content != NULL &&
+ style->uncommon->content != content)
+ style->alloc(style->uncommon->content, 0, style->pw);
+
style->uncommon->content = content;
return CSS_OK;
@@ -536,6 +555,10 @@ static inline css_error set_quotes(
*bits = (*bits & ~QUOTES_MASK) |
((type & 0x1) << QUOTES_SHIFT);
+ /* Free current quotes */
+ if (style->quotes != NULL && style->quotes != quotes)
+ style->alloc(style->quotes, 0, style->pw);
+
style->quotes = quotes;
return CSS_OK;
@@ -1446,6 +1469,10 @@ static inline css_error set_font_family(
*bits = (*bits & ~FONT_FAMILY_MASK) |
((type & 0x7) << FONT_FAMILY_SHIFT);
+ /* Free existing families */
+ if (style->font_family != NULL && style->font_family != names)
+ style->alloc(style->font_family, 0, style->pw);
+
style->font_family = names;
return CSS_OK;