summaryrefslogtreecommitdiff
path: root/content/handlers/html/textselection.c
diff options
context:
space:
mode:
Diffstat (limited to 'content/handlers/html/textselection.c')
-rw-r--r--content/handlers/html/textselection.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/content/handlers/html/textselection.c b/content/handlers/html/textselection.c
index 51c6ce1a9..cc08aeff2 100644
--- a/content/handlers/html/textselection.c
+++ b/content/handlers/html/textselection.c
@@ -444,7 +444,11 @@ selection_copy(struct box *box,
*/
static unsigned selection_label_subtree(struct box *box, unsigned idx)
{
- struct box *child = box->children;
+ struct box *child;
+
+ assert(box != NULL);
+
+ box = box->children;
box->byte_offset = idx;
@@ -475,6 +479,10 @@ html_textselection_redraw(struct content *c,
html_content *html = (html_content *)c;
struct rdw_info rdw;
+ if (html->layout == NULL) {
+ return NSERROR_INVALID;
+ }
+
rdw.inited = false;
res = coords_from_range(html->layout, start_idx, end_idx, &rdw, false);
@@ -505,6 +513,10 @@ html_textselection_copy(struct content *c,
save_text_whitespace before = WHITESPACE_NONE;
bool first = true;
+ if (html->layout == NULL) {
+ return NSERROR_INVALID;
+ }
+
return selection_copy(html->layout,
&html->len_ctx,
start_idx,
@@ -523,6 +535,10 @@ html_textselection_get_end(struct content *c, unsigned *end_idx)
html_content *html = (html_content *)c;
unsigned root_idx;
+ if (html->layout == NULL) {
+ return NSERROR_INVALID;
+ }
+
root_idx = 0;
*end_idx = selection_label_subtree(html->layout, root_idx);