diff --git a/MagickCore/widget.c b/MagickCore/widget.c
index db56bf5..21676c7 100644
--- a/MagickCore/widget.c
+++ b/MagickCore/widget.c
@@ -2254,8 +2254,9 @@
/*
User pressed mode button.
*/
- (void) CopyMagickString(reply_info.text,mode_info.text,
- MaxTextExtent);
+ if (mode_info.text != (char *) NULL)
+ (void) CopyMagickString(reply_info.text,mode_info.text,
+ MaxTextExtent);
(void) CopyMagickString(primary_selection,reply_info.text,
MaxTextExtent);
(void) XSetSelectionOwner(display,XA_PRIMARY,windows->widget.id,
diff --git a/MagickCore/xwindow.c b/MagickCore/xwindow.c
index 3d7fe23..95d8ba1 100644
--- a/MagickCore/xwindow.c
+++ b/MagickCore/xwindow.c
@@ -4434,17 +4434,20 @@
{
pixel=XGetPixel(ximage,x,y);
color=(pixel >> red_shift) & red_mask;
- color=(65535UL*color)/red_mask;
- SetPixelRed(composite_image,
- ScaleShortToQuantum((unsigned short) color),q);
+ if (red_mask != 0)
+ color=(65535UL*color)/red_mask;
+ SetPixelRed(composite_image,ScaleShortToQuantum(
+ (unsigned short) color),q);
color=(pixel >> green_shift) & green_mask;
- color=(65535UL*color)/green_mask;
- SetPixelGreen(composite_image,
- ScaleShortToQuantum((unsigned short) color),q);
+ if (green_mask != 0)
+ color=(65535UL*color)/green_mask;
+ SetPixelGreen(composite_image,ScaleShortToQuantum(
+ (unsigned short) color),q);
color=(pixel >> blue_shift) & blue_mask;
- color=(65535UL*color)/blue_mask;
- SetPixelBlue(composite_image,
- ScaleShortToQuantum((unsigned short) color),q);
+ if (blue_mask != 0)
+ color=(65535UL*color)/blue_mask;
+ SetPixelBlue(composite_image,ScaleShortToQuantum(
+ (unsigned short) color),q);
q+=GetPixelChannels(composite_image);
}
status=SyncCacheViewAuthenticPixels(composite_view,exception);