From 7a7a1aace5a5590c22d0b4e62ba726e8a8d876c3 Mon Sep 17 00:00:00 2001 From: "Boris I. Bendovsky" Date: Thu, 4 May 2023 12:16:42 +0300 Subject: [PATCH 1/2] Fix dereferencing null pointer in oggpack_writeinit --- src/bitwise.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitwise.c b/src/bitwise.c index f5ef7912..ad24cf55 100644 --- a/src/bitwise.c +++ b/src/bitwise.c @@ -39,7 +39,7 @@ static const unsigned int mask8B[]= void oggpack_writeinit(oggpack_buffer *b){ memset(b,0,sizeof(*b)); b->ptr=b->buffer=_ogg_malloc(BUFFER_INCREMENT); - b->buffer[0]='\0'; + if(b->buffer) b->buffer[0]='\0'; b->storage=BUFFER_INCREMENT; } From e3075c3528310e89b6c258f04262f08b47ad25d3 Mon Sep 17 00:00:00 2001 From: "Boris I. Bendovsky" Date: Thu, 4 May 2023 12:21:09 +0300 Subject: [PATCH 2/2] Fix type cast in ogg_page_serialno and ogg_page_pageno --- src/framing.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/framing.c b/src/framing.c index 724d116d..499bcc6e 100644 --- a/src/framing.c +++ b/src/framing.c @@ -60,17 +60,17 @@ ogg_int64_t ogg_page_granulepos(const ogg_page *og){ } int ogg_page_serialno(const ogg_page *og){ - return((int)((ogg_uint32_t)og->header[14]) | + return((int)(((ogg_uint32_t)og->header[14]) | ((ogg_uint32_t)og->header[15]<<8) | ((ogg_uint32_t)og->header[16]<<16) | - ((ogg_uint32_t)og->header[17]<<24)); + ((ogg_uint32_t)og->header[17]<<24))); } long ogg_page_pageno(const ogg_page *og){ - return((long)((ogg_uint32_t)og->header[18]) | + return((long)(((ogg_uint32_t)og->header[18]) | ((ogg_uint32_t)og->header[19]<<8) | ((ogg_uint32_t)og->header[20]<<16) | - ((ogg_uint32_t)og->header[21]<<24)); + ((ogg_uint32_t)og->header[21]<<24))); }