Gitweb links:
...log
http://git.netsurf-browser.org/libdom.git/shortlog/38c82c0d1e4474aff9b601fcf6ba9578396346b9
...commit
http://git.netsurf-browser.org/libdom.git/commit/38c82c0d1e4474aff9b601fcf6ba9578396346b9
...tree
http://git.netsurf-browser.org/libdom.git/tree/38c82c0d1e4474aff9b601fcf6ba9578396346b9
The branch, master has been updated
via 38c82c0d1e4474aff9b601fcf6ba9578396346b9 (commit)
from 010d1d5212cc906214feec4cfd25daca2dd2033e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/libdom.git/commit/?id=38c82c0d1e4474aff9b601fcf6ba9578396346b9
commit 38c82c0d1e4474aff9b601fcf6ba9578396346b9
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>
Deal with some scan-build-identified potential problems
Signed-off-by: Daniel Silverstone <[email protected]>
diff --git a/src/core/node.c b/src/core/node.c
index 87ad837..9ba277e 100644
--- a/src/core/node.c
+++ b/src/core/node.c
@@ -2172,7 +2172,9 @@ dom_exception _dom_node_detach_range(dom_node_internal
*first,
*
* This is not implemented in terms of attach/detach in case
* we want to perform any special replacement-related behaviour
- * at a later date.
+ * at a later date. If the replacement is essentially empty (either NULL
+ * or an empty document fragment node) then this essentially just removes
+ * the old node from its parent. It is up to the caller to deal with that.
*/
void _dom_node_replace(dom_node_internal *old,
dom_node_internal *replacement)
@@ -2190,6 +2192,19 @@ void _dom_node_replace(dom_node_internal *old,
last = replacement;
}
+ if (first == NULL) {
+ /* All we're doing is removing old */
+ if (old->previous == NULL) {
+ old->parent->first_child = old->next;
+ }
+ if (old->next == NULL) {
+ old->parent->last_child = old->previous;
+ }
+ old->previous = old->next = old->parent = NULL;
+ return;
+ }
+
+ /* We're replacing old with first-to-last */
first->previous = old->previous;
last->next = old->next;
diff --git a/src/html/html_select_element.c b/src/html/html_select_element.c
index ff549b2..0801d0a 100644
--- a/src/html/html_select_element.c
+++ b/src/html/html_select_element.c
@@ -213,6 +213,9 @@ dom_exception dom_html_select_element_get_selected_index(
dom_html_options_collection *col;
err = _dom_html_select_element_make_collection(ele, &col);
+ if (err != DOM_NO_ERR) {
+ return err;
+ }
err = dom_html_options_collection_get_length(col, &len);
if (err != DOM_NO_ERR) {
@@ -266,6 +269,9 @@ dom_exception dom_html_select_element_set_selected_index(
dom_html_options_collection *col;
err = _dom_html_select_element_make_collection(ele, &col);
+ if (err != DOM_NO_ERR) {
+ return err;
+ }
err = dom_html_options_collection_item(col,
index, &option);
-----------------------------------------------------------------------
Summary of changes:
src/core/node.c | 17 ++++++++++++++++-
src/html/html_select_element.c | 6 ++++++
2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/src/core/node.c b/src/core/node.c
index 87ad837..9ba277e 100644
--- a/src/core/node.c
+++ b/src/core/node.c
@@ -2172,7 +2172,9 @@ dom_exception _dom_node_detach_range(dom_node_internal
*first,
*
* This is not implemented in terms of attach/detach in case
* we want to perform any special replacement-related behaviour
- * at a later date.
+ * at a later date. If the replacement is essentially empty (either NULL
+ * or an empty document fragment node) then this essentially just removes
+ * the old node from its parent. It is up to the caller to deal with that.
*/
void _dom_node_replace(dom_node_internal *old,
dom_node_internal *replacement)
@@ -2190,6 +2192,19 @@ void _dom_node_replace(dom_node_internal *old,
last = replacement;
}
+ if (first == NULL) {
+ /* All we're doing is removing old */
+ if (old->previous == NULL) {
+ old->parent->first_child = old->next;
+ }
+ if (old->next == NULL) {
+ old->parent->last_child = old->previous;
+ }
+ old->previous = old->next = old->parent = NULL;
+ return;
+ }
+
+ /* We're replacing old with first-to-last */
first->previous = old->previous;
last->next = old->next;
diff --git a/src/html/html_select_element.c b/src/html/html_select_element.c
index ff549b2..0801d0a 100644
--- a/src/html/html_select_element.c
+++ b/src/html/html_select_element.c
@@ -213,6 +213,9 @@ dom_exception dom_html_select_element_get_selected_index(
dom_html_options_collection *col;
err = _dom_html_select_element_make_collection(ele, &col);
+ if (err != DOM_NO_ERR) {
+ return err;
+ }
err = dom_html_options_collection_get_length(col, &len);
if (err != DOM_NO_ERR) {
@@ -266,6 +269,9 @@ dom_exception dom_html_select_element_set_selected_index(
dom_html_options_collection *col;
err = _dom_html_select_element_make_collection(ele, &col);
+ if (err != DOM_NO_ERR) {
+ return err;
+ }
err = dom_html_options_collection_item(col,
index, &option);
--
Document Object Model library
_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org