libfreerdp-gdi: fix segfault in fast_index.
authorVic Lee <llyzs@163.com>
Tue, 20 Sep 2011 12:15:15 +0000 (20:15 +0800)
committerVic Lee <llyzs@163.com>
Tue, 20 Sep 2011 12:15:15 +0000 (20:15 +0800)
libfreerdp-core/orders.c
libfreerdp-gdi/gdi.c

index 079c8f1..6b99f30 100644 (file)
@@ -443,8 +443,8 @@ INLINE uint16 update_read_glyph_fragments(STREAM* s, GLYPH_FRAGMENT** fragments,
        array_mark = NULL;
        stream_end = s->p + size;
        stream_get_mark(s, stream_start);
-       offsets = (uint8**) xmalloc(size / 2);
-       lengths = (uint16*) xmalloc(size / 2);
+       offsets = (uint8**) xmalloc(sizeof(uint8*) * size / 2);
+       lengths = (uint16*) xmalloc(sizeof(uint16) * size / 2);
        operations = (uint8*) xmalloc(size / 2);
 
        while (s->p < stream_end)
index 39c121a..22f0e6b 100644 (file)
@@ -724,6 +724,9 @@ void gdi_fast_index(rdpUpdate* update, FAST_INDEX_ORDER* fast_index)
                        bmp = bmps[j];
                        glyph = glyphs[j];
 
+                       if (bmp == NULL || glyph == NULL)
+                               continue;
+
                        gdi_BitBlt(gdi->drawing->hdc, glyph->x + x, glyph->y + y, bmp->bitmap->width,
                                        bmp->bitmap->height, bmp->hdc, 0, 0, GDI_DSPDxax);