diff --git a/content/handlers/text/textplain.c b/content/handlers/text/textplain.c index c72846998..b5ad0aec3 100644 --- a/content/handlers/text/textplain.c +++ b/content/handlers/text/textplain.c @@ -1592,10 +1592,12 @@ textplain_textselection_copy(struct content *c, { const char *text; size_t length; - bool res; + bool res = false; text = textplain_get_raw_data(c, start_idx, end_idx, &length); - res = selection_string_append(text, length, false, NULL, selstr); + if (text != NULL) { + res = selection_string_append(text, length, false, NULL, selstr); + } if (res == false) { return NSERROR_NOMEM; }