lavu/imgutils: add consistency checks to av_image_copy_plane()

Add assertions and abort in case of invalid |dst_linesize| < bytewidth or
|src_linesize| < bytewidth.

Avoid to silently corrupt memory.
This commit is contained in:
Stefano Sabatini 2012-09-08 00:31:41 +02:00
parent 26c531cc22
commit 252746d052
3 changed files with 7 additions and 1 deletions

View file

@ -21,6 +21,7 @@
* misc image utilities
*/
#include "avassert.h"
#include "common.h"
#include "imgutils.h"
#include "internal.h"
@ -244,6 +245,8 @@ void av_image_copy_plane(uint8_t *dst, int dst_linesize,
{
if (!dst || !src)
return;
av_assert0(abs(src_linesize) >= bytewidth);
av_assert0(abs(dst_linesize) >= bytewidth);
for (;height > 0; height--) {
memcpy(dst, src, bytewidth);
dst += dst_linesize;