core/glyph: copy data when adding glyph to cache

fixes #1500
This commit is contained in:
Bernhard Miklautz 2013-09-24 23:25:18 +02:00
parent 1ffdeea1fc
commit c99d9ee72b
3 changed files with 9 additions and 12 deletions

View File

@ -277,7 +277,7 @@ void update_gdi_fast_glyph(rdpContext* context, FAST_GLYPH_ORDER* fast_glyph)
if (y == -32768) if (y == -32768)
y = fast_glyph->bkTop; y = fast_glyph->bkTop;
if (fast_glyph->cbData > 1) if (fast_glyph->cbData > 1 && NULL != fast_glyph->glyphData.aj)
{ {
/* got option font that needs to go into cache */ /* got option font that needs to go into cache */
glyph_data = &fast_glyph->glyphData; glyph_data = &fast_glyph->glyphData;
@ -288,7 +288,8 @@ void update_gdi_fast_glyph(rdpContext* context, FAST_GLYPH_ORDER* fast_glyph)
glyph->cx = glyph_data->cx; glyph->cx = glyph_data->cx;
glyph->cy = glyph_data->cy; glyph->cy = glyph_data->cy;
glyph->cb = glyph_data->cb; glyph->cb = glyph_data->cb;
glyph->aj = glyph_data->aj; glyph->aj = malloc(glyph_data->cb);
CopyMemory(glyph->aj, glyph_data->aj, glyph->cb);
Glyph_New(context, glyph); Glyph_New(context, glyph);
glyph_cache_put(cache->glyph, fast_glyph->cacheId, fast_glyph->data[0], glyph); glyph_cache_put(cache->glyph, fast_glyph->cacheId, fast_glyph->data[0], glyph);
@ -368,16 +369,14 @@ rdpGlyph* glyph_cache_get(rdpGlyphCache* glyph_cache, UINT32 id, UINT32 index)
if (index > glyph_cache->glyphCache[id].number) if (index > glyph_cache->glyphCache[id].number)
{ {
fprintf(stderr, "invalid glyph cache index: %d in cache id: %d\n", index, id); fprintf(stderr, "index %d out of range for cache id: %d\n", index, id);
return NULL; return NULL;
} }
glyph = glyph_cache->glyphCache[id].entries[index]; glyph = glyph_cache->glyphCache[id].entries[index];
if (glyph == NULL) if (glyph == NULL)
{ fprintf(stderr, "no glyph found at cache index: %d in cache id: %d\n", index, id);
fprintf(stderr, "invalid glyph at cache index: %d in cache id: %d\n", index, id);
}
return glyph; return glyph;
} }
@ -419,9 +418,7 @@ void* glyph_cache_fragment_get(rdpGlyphCache* glyph_cache, UINT32 index, UINT32*
*size = (BYTE) glyph_cache->fragCache.entries[index].size; *size = (BYTE) glyph_cache->fragCache.entries[index].size;
if (fragment == NULL) if (fragment == NULL)
{
fprintf(stderr, "invalid glyph fragment at index:%d\n", index); fprintf(stderr, "invalid glyph fragment at index:%d\n", index);
}
return fragment; return fragment;
} }
@ -436,9 +433,7 @@ void glyph_cache_fragment_put(rdpGlyphCache* glyph_cache, UINT32 index, UINT32 s
glyph_cache->fragCache.entries[index].size = size; glyph_cache->fragCache.entries[index].size = size;
if (prevFragment != NULL) if (prevFragment != NULL)
{
free(prevFragment); free(prevFragment);
}
} }
void glyph_cache_register_callbacks(rdpUpdate* update) void glyph_cache_register_callbacks(rdpUpdate* update)

View File

@ -485,9 +485,7 @@ static INLINE BOOL update_write_4byte_unsigned(wStream* s, UINT32 value)
Stream_Write_UINT8(s, byte); Stream_Write_UINT8(s, byte);
} }
else else
{
return FALSE; return FALSE;
}
return TRUE; return TRUE;
} }
@ -1670,6 +1668,8 @@ BOOL update_read_fast_glyph_order(wStream* s, ORDER_INFO* orderInfo, FAST_GLYPH_
if (Stream_GetRemainingLength(s) < glyph->cb) if (Stream_GetRemainingLength(s) < glyph->cb)
return FALSE; return FALSE;
if (glyph->aj)
free(glyph->aj);
glyph->aj = (BYTE*) malloc(glyph->cb); glyph->aj = (BYTE*) malloc(glyph->cb);
Stream_Read(s, glyph->aj, glyph->cb); Stream_Read(s, glyph->aj, glyph->cb);
} }

View File

@ -1609,6 +1609,8 @@ void update_free(rdpUpdate* update)
free(update->primary->polyline.points); free(update->primary->polyline.points);
free(update->primary->polygon_sc.points); free(update->primary->polygon_sc.points);
if (NULL != update->primary->fast_glyph.glyphData.aj)
free(update->primary->fast_glyph.glyphData.aj);
free(update->primary); free(update->primary);
free(update->secondary); free(update->secondary);