Browse Source

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.
tags/n1.1
Stefano Sabatini 12 years ago
parent
commit
252746d052
3 changed files with 7 additions and 1 deletions
  1. +3
    -0
      libavutil/imgutils.c
  2. +3
    -0
      libavutil/imgutils.h
  3. +1
    -1
      libavutil/version.h

+ 3
- 0
libavutil/imgutils.c View File

@@ -21,6 +21,7 @@
* misc image utilities * misc image utilities
*/ */


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


+ 3
- 0
libavutil/imgutils.h View File

@@ -99,6 +99,9 @@ int av_image_alloc(uint8_t *pointers[4], int linesizes[4],
* The first byte of each successive line is separated by *_linesize * The first byte of each successive line is separated by *_linesize
* bytes. * bytes.
* *
* bytewidth must be contained by both absolute values of dst_linesize
* and src_linesize, otherwise the function behavior is undefined.
*
* @param dst_linesize linesize for the image plane in dst * @param dst_linesize linesize for the image plane in dst
* @param src_linesize linesize for the image plane in src * @param src_linesize linesize for the image plane in src
*/ */


+ 1
- 1
libavutil/version.h View File

@@ -76,7 +76,7 @@


#define LIBAVUTIL_VERSION_MAJOR 52 #define LIBAVUTIL_VERSION_MAJOR 52
#define LIBAVUTIL_VERSION_MINOR 9 #define LIBAVUTIL_VERSION_MINOR 9
#define LIBAVUTIL_VERSION_MICRO 100
#define LIBAVUTIL_VERSION_MICRO 101


#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \ LIBAVUTIL_VERSION_MINOR, \


Loading…
Cancel
Save