summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2008-08-13 16:25:54 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2008-08-13 16:25:54 +0000
commit8e108e1e513f8bcaeb90c22915afdac426e7782d (patch)
tree71cb3f241a2b5dd3fcfa630ab0eeb14b0c08591e /src
parent900ca733a75a7ad72119cde74ee6a99ab082d24d (diff)
downloadlibhubbub-8e108e1e513f8bcaeb90c22915afdac426e7782d.tar.gz
libhubbub-8e108e1e513f8bcaeb90c22915afdac426e7782d.tar.bz2
Fix segfault in elimination of duplicate attributes.
svn path=/trunk/hubbub/; revision=5098
Diffstat (limited to 'src')
-rw-r--r--src/tokeniser/tokeniser.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/tokeniser/tokeniser.c b/src/tokeniser/tokeniser.c
index 755b3b5..1fdaddb 100644
--- a/src/tokeniser/tokeniser.c
+++ b/src/tokeniser/tokeniser.c
@@ -2861,19 +2861,20 @@ hubbub_error emit_current_tag(hubbub_tokeniser *tokeniser)
continue;
}
+ assert(i < j);
+
/* Calculate amount to move */
- move = (n_attributes - 1 -
- ((i < j) ? j : i)) *
+ move = (n_attributes - 1 - j) *
sizeof(hubbub_attribute);
if (move > 0) {
- memmove((i < j) ? &attrs[j]
- : &attrs[i],
- (i < j) ? &attrs[j+1]
- : &attrs[i+1],
- move);
+ memmove(&attrs[j],&attrs[j+1], move);
}
+ /* We've deleted an item, so we need to
+ * reprocess this index */
+ j--;
+
/* And reduce the number of attributes */
n_attributes--;
}