@@ -160,6 +160,14 @@ protected override void CreateOrUpdateBitmap(bool isPopup, Rect dirtyRect, IntPt
160
160
return ;
161
161
}
162
162
163
+ var sourceBufferPtr = sourceBuffer . DangerousGetHandle ( ) ;
164
+
165
+ // Issue https://github.com/cefsharp/CefSharp/issues/4426
166
+ if ( sourceBufferPtr == IntPtr . Zero )
167
+ {
168
+ return ;
169
+ }
170
+
163
171
//By default we'll only update the dirty rect, for those that run into a MILERR_WIN32ERROR Exception (#2035)
164
172
//it's desirably to either upgrade to a newer .Net version (only client runtime needs to be installed, not compiled
165
173
//against a newer version. Or invalidate the whole bitmap
@@ -169,7 +177,7 @@ protected override void CreateOrUpdateBitmap(bool isPopup, Rect dirtyRect, IntPt
169
177
var sourceRect = new Int32Rect ( dirtyRect . X , dirtyRect . Y , dirtyRect . Width , dirtyRect . Height ) ;
170
178
171
179
bitmap . Lock ( ) ;
172
- bitmap . WritePixels ( sourceRect , sourceBuffer . DangerousGetHandle ( ) , noOfBytes , stride , dirtyRect . X , dirtyRect . Y ) ;
180
+ bitmap . WritePixels ( sourceRect , sourceBufferPtr , noOfBytes , stride , dirtyRect . X , dirtyRect . Y ) ;
173
181
bitmap . Unlock ( ) ;
174
182
}
175
183
else
@@ -178,7 +186,7 @@ protected override void CreateOrUpdateBitmap(bool isPopup, Rect dirtyRect, IntPt
178
186
var sourceRect = new Int32Rect ( 0 , 0 , width , height ) ;
179
187
180
188
bitmap . Lock ( ) ;
181
- bitmap . WritePixels ( sourceRect , sourceBuffer . DangerousGetHandle ( ) , noOfBytes , stride ) ;
189
+ bitmap . WritePixels ( sourceRect , sourceBufferPtr , noOfBytes , stride ) ;
182
190
bitmap . Unlock ( ) ;
183
191
}
184
192
}
0 commit comments