@@ -28,10 +28,10 @@
#include "ass.h"
#include "libavutil/bprint.h"
-static int subviewer_event_to_ass(AVBPrint *buf, const char *p)
+static int subviewer_event_to_ass(AVBPrint *buf, const char *p, const char *pend)
{
- while (*p) {
- if (!strncmp(p, "[br]", 4)) {
+ while (p < pend && *p) {
+ if (pend - p >= 4 && !strncmp(p, "[br]", 4)) {
av_bprintf(buf, "\\N");
p += 4;
} else {
@@ -56,7 +56,7 @@ static int subviewer_decode_frame(AVCodecContext *avctx,
AVBPrint buf;
av_bprint_init(&buf, 0, AV_BPRINT_SIZE_UNLIMITED);
- if (ptr && avpkt->size > 0 && !subviewer_event_to_ass(&buf, ptr))
+ if (ptr && avpkt->size > 0 && !subviewer_event_to_ass(&buf, ptr, ptr + avpkt->size))
ret = ff_ass_add_rect(sub, buf.str, s->readorder++, 0, NULL, NULL);
av_bprint_finalize(&buf, NULL);
if (ret < 0)
Signed-off-by: Marton Balint <cus@passwd.hu> --- libavcodec/subviewerdec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)