From a19b442375b67565065f9432c915dd407a99d62e Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 6 Jul 2021 19:25:00 +0200 Subject: [PATCH] Prevent crash --- app/src/main/java/eu/faircode/email/StyleHelper.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/StyleHelper.java b/app/src/main/java/eu/faircode/email/StyleHelper.java index 1b49dbb1f6..b714e79921 100644 --- a/app/src/main/java/eu/faircode/email/StyleHelper.java +++ b/app/src/main/java/eu/faircode/email/StyleHelper.java @@ -351,6 +351,9 @@ public class StyleHelper { Log.breadcrumb("style", "action", "alignment"); Pair paragraph = ensureParagraph(edit, start, end); + if (paragraph == null) + return false; + int s = paragraph.first; int e = paragraph.second; @@ -421,6 +424,9 @@ public class StyleHelper { float textSize = Helper.getTextSize(context, 0) * message_zoom / 100f; Pair paragraph = ensureParagraph(edit, start, end); + if (paragraph == null) + return false; + int s = paragraph.first; int e = paragraph.second; @@ -494,6 +500,8 @@ public class StyleHelper { int quoteStripe = context.getResources().getDimensionPixelSize(R.dimen.quote_stripe_width); Pair paragraph = ensureParagraph(edit, start, end); + if (paragraph == null) + return false; QuoteSpan q; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) @@ -680,6 +688,8 @@ public class StyleHelper { else if (span instanceof QuoteSpan) { ParagraphStyle ps = (ParagraphStyle) span; Pair p = ensureParagraph(edit, start, end); + if (p == null) + return; edit.setSpan(clone(span, ps.getClass(), context), p.first, p.second, flags); } }