[haiku-commits] haiku: hrev53380 - src/servers/app/drawing

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 16 Aug 2019 00:25:49 -0400 (EDT)

hrev53380 adds 1 changeset to branch 'master'
old head: fe08f0b3d0489bded18325689900a99dbad40694
new head: b5be469eee595f20dc4ff094869fe16611953151
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=b5be469eee59+%5Efe08f0b3d048

----------------------------------------------------------------------------

b5be469eee59: app_server: some missing std::nothrow and error checks.
  
  I had app_server crash on me because of an uncaught allocation
  exception. I don't know if this will fix it but it's better to try to
  survive even if it may result in some UI glitches.
  
  Change-Id: I09dd2a7e6ff63d52f51389d7418d1a1d1810af00
  Reviewed-on: https://review.haiku-os.org/c/haiku/+/1720
  Reviewed-by: waddlesplash <waddlesplash@xxxxxxxxx>

                             [ Adrien Destugues <pulkomandy@xxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev53380
Commit:      b5be469eee595f20dc4ff094869fe16611953151
URL:         https://git.haiku-os.org/haiku/commit/?id=b5be469eee59
Author:      Adrien Destugues <pulkomandy@xxxxxxxxxxxxx>
Date:        Thu Aug 15 16:01:32 2019 UTC
Committer:   waddlesplash <waddlesplash@xxxxxxxxx>
Commit-Date: Fri Aug 16 04:25:44 2019 UTC

----------------------------------------------------------------------------

3 files changed, 18 insertions(+), 5 deletions(-)
src/servers/app/drawing/DrawingEngine.cpp | 11 ++++++++---
src/servers/app/drawing/HWInterface.cpp   |  8 +++++++-
src/servers/app/drawing/HWInterface.h     |  4 +++-

----------------------------------------------------------------------------

diff --git a/src/servers/app/drawing/DrawingEngine.cpp 
b/src/servers/app/drawing/DrawingEngine.cpp
index d3df91dc49..c4e50f6da0 100644
--- a/src/servers/app/drawing/DrawingEngine.cpp
+++ b/src/servers/app/drawing/DrawingEngine.cpp
@@ -428,7 +428,7 @@ struct node {
        void init(const BRect& r, int32 maxPointers)
        {
                rect = r;
-               pointers = new node*[maxPointers];
+               pointers = new(std::nothrow) node*[maxPointers];
                in_degree = 0;
                next_pointer = 0;
        }
@@ -490,6 +490,8 @@ DrawingEngine::CopyRegion(/*const*/ BRegion* region, int32 
xOffset,
        BStackOrHeapArray<node, 64> nodes(count);
        for (int32 i= 0; i < count; i++) {
                nodes[i].init(region->RectAt(i), count);
+               if (nodes[i].pointers == NULL)
+                       return;
        }
 
        for (int32 i = 0; i < count; i++) {
@@ -551,8 +553,11 @@ DrawingEngine::CopyRegion(/*const*/ BRegion* region, int32 
xOffset,
        clipping_rect* sortedRectList = NULL;
        int32 nextSortedIndex = 0;
 
-       if (fAvailableHWAccleration & HW_ACC_COPY_REGION)
-               sortedRectList = new clipping_rect[count];
+       if (fAvailableHWAccleration & HW_ACC_COPY_REGION) {
+               sortedRectList = new(std::nothrow) clipping_rect[count];
+               if (sortedRectList == NULL)
+                       return;
+       }
 
        while (!inDegreeZeroNodes.empty()) {
                node* n = inDegreeZeroNodes.top();
diff --git a/src/servers/app/drawing/HWInterface.cpp 
b/src/servers/app/drawing/HWInterface.cpp
index cf9a67223a..e98bc51deb 100644
--- a/src/servers/app/drawing/HWInterface.cpp
+++ b/src/servers/app/drawing/HWInterface.cpp
@@ -586,8 +586,10 @@ HWInterface::_DrawCursor(IntRect area) const
                // that has the cursor blended on top of it
 
                // blending buffer
-               uint8* buffer = new uint8[width * height * 4];
+               uint8* buffer = new(std::nothrow) uint8[width * height * 4];
                        // TODO: cache this buffer
+               if (buffer == NULL)
+                       return;
 
                // offset into back buffer
                uint8* src = (uint8*)backBuffer->Bits();
@@ -1085,6 +1087,10 @@ HWInterface::_AdoptDragBitmap(const ServerBitmap* 
bitmap, const BPoint& offset)
                BRect cursorBounds = fCursorAndDragBitmap->Bounds();
                fCursorAreaBackup = new buffer_clip(cursorBounds.IntegerWidth() 
+ 1,
                        cursorBounds.IntegerHeight() + 1);
+               if (fCursorAreaBackup->buffer == NULL) {
+                       delete fCursorAreaBackup;
+                       fCursorAreaBackup = NULL;
+               }
        }
        _DrawCursor(_CursorFrame());
 }
diff --git a/src/servers/app/drawing/HWInterface.h 
b/src/servers/app/drawing/HWInterface.h
index aaf79194a0..11242f06c4 100644
--- a/src/servers/app/drawing/HWInterface.h
+++ b/src/servers/app/drawing/HWInterface.h
@@ -18,6 +18,8 @@
 
 #include <video_overlay.h>
 
+#include <new>
+
 #include "IntRect.h"
 #include "MultiLocker.h"
 #include "ServerCursor.h"
@@ -224,7 +226,7 @@ protected:
                                {
                                        bpr = width * 4;
                                        if (bpr > 0 && height > 0)
-                                               buffer = new uint8[bpr * 
height];
+                                               buffer = new(std::nothrow) 
uint8[bpr * height];
                                        else
                                                buffer = NULL;
                                        left = 0;


Other related posts:

  • » [haiku-commits] haiku: hrev53380 - src/servers/app/drawing - waddlesplash