Mercurial > mplayer.hg
comparison libass/ass_render.c @ 29381:fd2047f3adf6
Fix read after the end of allocated buffer.
author | eugeni |
---|---|
date | Sat, 18 Jul 2009 11:32:58 +0000 |
parents | 0f1b5b68af32 |
children | 363310571aae |
comparison
equal
deleted
inserted
replaced
29380:c15ef485f8aa | 29381:fd2047f3adf6 |
---|---|
406 } | 406 } |
407 return tail; | 407 return tail; |
408 } | 408 } |
409 | 409 |
410 /** | 410 /** |
411 * \brief Replaces the bitmap buffer in ass_image_t with its copy. | |
412 * | |
413 * @param img Image to operate on. | |
414 * @return Address of the old buffer. | |
415 */ | |
416 static unsigned char* clone_bitmap_data(ass_image_t* img) | |
417 { | |
418 unsigned char* old_bitmap = img->bitmap; | |
419 int size = img->stride * (img->h - 1) + img->w; | |
420 img->bitmap = malloc(size); | |
421 memcpy(img->bitmap, old_bitmap, size); | |
422 return old_bitmap; | |
423 } | |
424 | |
425 /** | |
411 * \brief Calculate overlapping area of two consecutive bitmaps and in case they | 426 * \brief Calculate overlapping area of two consecutive bitmaps and in case they |
412 * overlap, composite them together | 427 * overlap, composite them together |
413 * Mainly useful for translucent glyphs and especially borders, to avoid the | 428 * Mainly useful for translucent glyphs and especially borders, to avoid the |
414 * luminance adding up where they overlap (which looks ugly) | 429 * luminance adding up where they overlap (which looks ugly) |
415 */ | 430 */ |
472 (*tail)->bitmap = hv->b; | 487 (*tail)->bitmap = hv->b; |
473 return; | 488 return; |
474 } | 489 } |
475 | 490 |
476 // Allocate new bitmaps and copy over data | 491 // Allocate new bitmaps and copy over data |
477 a = (*last_tail)->bitmap; | 492 a = clone_bitmap_data(*last_tail); |
478 b = (*tail)->bitmap; | 493 b = clone_bitmap_data(*tail); |
479 (*last_tail)->bitmap = malloc(as*ah); | |
480 (*tail)->bitmap = malloc(bs*bh); | |
481 memcpy((*last_tail)->bitmap, a, as*ah); | |
482 memcpy((*tail)->bitmap, b, bs*bh); | |
483 | 494 |
484 // Composite overlapping area | 495 // Composite overlapping area |
485 for (y=0; y<h; y++) | 496 for (y=0; y<h; y++) |
486 for (x=0; x<w; x++) { | 497 for (x=0; x<w; x++) { |
487 opos = (old_top+y)*(as) + (old_left+x); | 498 opos = (old_top+y)*(as) + (old_left+x); |