From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> To: ffmpeg-devel@ffmpeg.org Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Subject: [FFmpeg-devel] [PATCH 7/7] avcodec/fraps: Fix segfault with negative linesizes Date: Fri, 30 Sep 2022 19:05:15 +0200 Message-ID: <GV1P250MB07372CA9E506502EDFAAAB1B8F569@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM> (raw) In-Reply-To: <GV1P250MB073747D27D2794CFC913647A8F569@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM> Using unsigned and negative linesizes doesn't really work. Use ptrdiff_t instead. This fixes the fraps-v0 and fraps-v1 FATE tests with negative linesizes. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/fraps.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libavcodec/fraps.c b/libavcodec/fraps.c index 9c8cbf7323..4c4c46b602 100644 --- a/libavcodec/fraps.c +++ b/libavcodec/fraps.c @@ -141,7 +141,6 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *f, int buf_size = avpkt->size; uint32_t header; unsigned int version,header_size; - unsigned int x, y; const uint32_t *buf32; uint32_t *luma1,*luma2,*cb,*cr; uint32_t offs[4]; @@ -238,12 +237,12 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *f, } buf32 = (const uint32_t*)buf; - for (y = 0; y < avctx->height / 2; y++) { + for (ptrdiff_t y = 0; y < avctx->height / 2; y++) { luma1 = (uint32_t*)&f->data[0][ y * 2 * f->linesize[0] ]; luma2 = (uint32_t*)&f->data[0][ (y * 2 + 1) * f->linesize[0] ]; cr = (uint32_t*)&f->data[1][ y * f->linesize[1] ]; cb = (uint32_t*)&f->data[2][ y * f->linesize[2] ]; - for (x = 0; x < avctx->width; x += 8) { + for (ptrdiff_t x = 0; x < avctx->width; x += 8) { *luma1++ = *buf32++; *luma1++ = *buf32++; *luma2++ = *buf32++; @@ -258,18 +257,18 @@ static int decode_frame(AVCodecContext *avctx, AVFrame *f, if (is_pal) { uint32_t *pal = (uint32_t *)f->data[1]; - for (y = 0; y < 256; y++) { + for (unsigned y = 0; y < 256; y++) { pal[y] = AV_RL32(buf) | 0xFF000000; buf += 4; } - for (y = 0; y <avctx->height; y++) + for (ptrdiff_t y = 0; y < avctx->height; y++) memcpy(&f->data[0][y * f->linesize[0]], &buf[y * avctx->width], avctx->width); } else { /* Fraps v1 is an upside-down BGR24 */ - for (y = 0; y<avctx->height; y++) + for (ptrdiff_t y = 0; y < avctx->height; y++) memcpy(&f->data[0][(avctx->height - y - 1) * f->linesize[0]], &buf[y * avctx->width * 3], 3 * avctx->width); -- 2.34.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2022-09-30 17:06 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-09-30 17:02 [FFmpeg-devel] [PATCH 1/7] avcodec/sunrast: Use ptrdiff_t for stride Andreas Rheinhardt 2022-09-30 17:05 ` [FFmpeg-devel] [PATCH 2/7] avcodec/sgidec: Support negative linesizes Andreas Rheinhardt 2022-09-30 17:05 ` [FFmpeg-devel] [PATCH 3/7] avcodec/sgidec: Avoid redundant private context Andreas Rheinhardt 2022-10-04 14:42 ` Tomas Härdin 2022-09-30 17:05 ` [FFmpeg-devel] [PATCH 4/7] avcodec/sgidec: Use planar pixel formats Andreas Rheinhardt 2022-09-30 17:05 ` [FFmpeg-devel] [PATCH 5/7] avcodec/c93: Fix segfault when using negative linesizes Andreas Rheinhardt 2022-09-30 17:05 ` [FFmpeg-devel] [PATCH 6/7] avcodec/escape124: Fix segfault with " Andreas Rheinhardt 2022-09-30 17:05 ` Andreas Rheinhardt [this message] 2022-10-03 22:05 ` [FFmpeg-devel] [PATCH 1/7] avcodec/sunrast: Use ptrdiff_t for stride Andreas Rheinhardt 2022-10-04 0:03 ` James Almer 2022-10-04 0:25 ` Andreas Rheinhardt
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=GV1P250MB07372CA9E506502EDFAAAB1B8F569@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM \ --to=andreas.rheinhardt@outlook.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git