diff options
Diffstat (limited to 'desktop/selection.c')
-rw-r--r-- | desktop/selection.c | 15 |
1 files changed, 9 insertions, 6 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); |