Description: vga-vmware + vnc: don't try to set_bit to negative offsets
 If x or y < 0, set them to 0 (and decrement width/height accordingly)
Author: Serge Hallyn <serge.hallyn@ubuntu.com>
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/qemu-kvm/+bug/918791
Forwarded: yes

Index: qemu-kvm/hw/vmware_vga.c
===================================================================
--- qemu-kvm.orig/hw/vmware_vga.c	2012-09-12 10:31:11.288199662 -0500
+++ qemu-kvm/hw/vmware_vga.c	2012-09-12 10:40:56.219100178 -0500
@@ -298,6 +298,24 @@
     uint8_t *src;
     uint8_t *dst;
 
+    if (x < 0) {
+        fprintf(stderr, "%s: update x was < 0 (%d, w %d)\n",
+                        __FUNCTION__, x, w);
+        w += x;
+        if (w < 0) {
+            return;
+        }
+        x = 0;
+    }
+    if (y < 0) {
+        fprintf(stderr, "%s: update y was < 0 (%d, h %d)\n",
+                        __FUNCTION__, y, h);
+        h += y;
+        if (h < 0) {
+            return;
+        }
+        y = 0;
+    }
     if (x + w > s->width) {
         fprintf(stderr, "%s: update width too large x: %d, w: %d\n",
                         __FUNCTION__, x, w);
