From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: alina sireneva <alina@tei.su>
Date: Fri, 17 Jul 2026 19:59:53 +0400
Subject: Fix crash drawing recycled source bitmap during sticker segmentation

---
 .../telegram/ui/Components/Paint/Views/StickerMakerView.java  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Paint/Views/StickerMakerView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Paint/Views/StickerMakerView.java
index 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Paint/Views/StickerMakerView.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Paint/Views/StickerMakerView.java
@@ -785,7 +785,7 @@ public class StickerMakerView extends FrameLayout implements NotificationCenter.
 
     private Bitmap createSmoothEdgesSegmentedImage(int x, int y, Bitmap inputBitmap, boolean full) {
         Bitmap srcBitmap = getSourceBitmap();
-        if (inputBitmap == null || inputBitmap.isRecycled() || srcBitmap == null) {
+        if (inputBitmap == null || inputBitmap.isRecycled() || srcBitmap == null || srcBitmap.isRecycled()) {
             return null;
         }
         Paint bitmapPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
@@ -831,7 +831,7 @@ public class StickerMakerView extends FrameLayout implements NotificationCenter.
             final ArrayList<SegmentedObject> finalObjects = new ArrayList<>();
 
             Utilities.themeQueue.postRunnable(() -> {
-                if (sourceBitmap == null || segmentingLoaded) return;
+                if (sourceBitmap == null || sourceBitmap.isRecycled() || segmentingLoaded) return;
                 Matrix matrix = new Matrix();
                 matrix.postScale(1f / sourceBitmap.getWidth(), 1f / sourceBitmap.getHeight());
                 matrix.postTranslate(-.5f, -.5f);
