diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2006-04-26 17:26:03 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2006-04-26 17:26:03 +0000 |
commit | 37cb487fc01324c0c59bd0d6d350bb07c4e6a3a8 (patch) | |
tree | a7d9b18074d8ba50b4f00b0f8f2d0e034600a0db | |
parent | fba9652abb348b8e9dfe6845a1762ab4f02971a1 (diff) | |
download | netsurf-37cb487fc01324c0c59bd0d6d350bb07c4e6a3a8.tar.gz netsurf-37cb487fc01324c0c59bd0d6d350bb07c4e6a3a8.tar.bz2 |
Fix crash when saving a selection after its containing window's content
has changed.
svn path=/trunk/netsurf/; revision=2557
-rw-r--r-- | desktop/selection.c | 15 | ||||
-rw-r--r-- | riscos/save.c | 3 |
2 files changed, 11 insertions, 7 deletions
diff --git a/desktop/selection.c b/desktop/selection.c index 829014f10..694bf5502 100644 --- a/desktop/selection.c +++ b/desktop/selection.c @@ -372,7 +372,7 @@ bool selected_part(struct box *box, unsigned start_idx, unsigned end_idx, if (box_length > 0) { if (box->byte_offset >= start_idx && box->byte_offset + box_length <= end_idx) { - + /* fully enclosed */ *start_offset = 0; *end_offset = box_length; @@ -383,18 +383,18 @@ bool selected_part(struct box *box, unsigned start_idx, unsigned end_idx, /* partly enclosed */ int offset = 0; int len; - + if (box->byte_offset < start_idx) offset = start_idx - box->byte_offset; - + len = box_length - offset; - + if (box->byte_offset + box_length > end_idx) len = end_idx - (box->byte_offset + offset); - + *start_offset = offset; *end_offset = offset + len; - + return true; } } @@ -870,6 +870,9 @@ bool selection_save_text(struct selection *s, const char *path) return false; } + if (!sv.block) + return false; + ret = utf8_to_local_encoding(sv.block, sv.length, &result); free(sv.block); diff --git a/riscos/save.c b/riscos/save.c index 67a860ee1..c9a1e6378 100644 --- a/riscos/save.c +++ b/riscos/save.c @@ -692,7 +692,8 @@ bool ro_gui_save_content(struct content *c, char *path) break; case GUI_SAVE_TEXT_SELECTION: - selection_save_text(gui_save_selection, path); + if (!selection_save_text(gui_save_selection, path)) + return false; xosfile_set_type(path, 0xfff); break; |