spice: fix coverity reported defect in display code
commit51a090991449c7d3c6d428eda18b4f30a36e2c1b
authorGerd Hoffmann <kraxel@redhat.com>
Thu, 15 Jan 2015 11:06:16 +0000 (15 12:06 +0100)
committerGerd Hoffmann <kraxel@redhat.com>
Thu, 22 Jan 2015 10:18:41 +0000 (22 11:18 +0100)
treeaaf96f3e56f74c952ddde71bd5eb411e9e669b52
parentfe4831b1e7e7007ae15ae0470a06898660ab3877
spice: fix coverity reported defect in display code

Report:

1. Condition surface, taking false branch
406    if (surface && ssd->surface &&
407        surface_width(surface) == pixman_image_get_width(ssd->surface) &&
408        surface_height(surface) == pixman_image_get_height(ssd->surface)) {
409        /* no-resize fast path: just swap backing store */
...

10. alias_transfer: Assigning: ssd->ds = surface.
440    ssd->ds = surface;

11. var_deref_op: Dereferencing null pointer ssd->ds.
CID 1264334 (#1 of 1): Dereference after null check (FORWARD_NULL)
441    ssd->surface = pixman_image_ref(ssd->ds->image);

Fix:

Move code block dereferencing ssd->ds into the already existing
if (ssd->ds) { ... } block.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
ui/spice-display.c