debuggers.hg

changeset 17307:c8c8b5c5f6d7

ioemu: Fix vnc buffer sharing when linesize != width * depth.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Mar 20 18:28:52 2008 +0000 (2008-03-20)
parents 491a3b62ae5b
children 76c9cf11ce23 42f6c206c951
files tools/ioemu/vnc.c
line diff
     1.1 --- a/tools/ioemu/vnc.c	Thu Mar 20 17:48:02 2008 +0000
     1.2 +++ b/tools/ioemu/vnc.c	Thu Mar 20 18:28:52 2008 +0000
     1.3 @@ -370,16 +370,20 @@ static void vnc_dpy_resize(DisplayState 
     1.4      int o;
     1.5  
     1.6      if (!ds->shared_buf) {
     1.7 +        ds->linesize = w * vs->depth;
     1.8          if (allocated)
     1.9 -            ds->data = realloc(ds->data,  h * linesize);
    1.10 +            ds->data = realloc(ds->data,  h * ds->linesize);
    1.11          else
    1.12 -            ds->data = malloc(h * linesize);
    1.13 +            ds->data = malloc(h * ds->linesize);
    1.14          allocated = 1;
    1.15 -    } else if (allocated) {
    1.16 -        free(ds->data);
    1.17 -        allocated = 0;
    1.18 +    } else {
    1.19 +        ds->linesize = linesize;
    1.20 +        if (allocated) {
    1.21 +            free(ds->data);
    1.22 +            allocated = 0;
    1.23 +        }
    1.24      }
    1.25 -    vs->old_data = realloc(vs->old_data, h * linesize);
    1.26 +    vs->old_data = realloc(vs->old_data, h * ds->linesize);
    1.27      vs->dirty_row = realloc(vs->dirty_row, h * sizeof(vs->dirty_row[0]));
    1.28      vs->update_row = realloc(vs->update_row, h * sizeof(vs->dirty_row[0]));
    1.29  
    1.30 @@ -396,7 +400,6 @@ static void vnc_dpy_resize(DisplayState 
    1.31      size_changed = ds->width != w || ds->height != h;
    1.32      ds->width = w;
    1.33      ds->height = h;
    1.34 -    ds->linesize = linesize;
    1.35      if (vs->csock != -1 && vs->has_resize && size_changed) {
    1.36          vs->width = ds->width;
    1.37          vs->height = ds->height;