Skip to content

Small fixes #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bitwise.c
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This do not look correct. If malloc() fail, I doubt b->storage should get a non-zero value as the there is no storage available.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This do not look correct. If malloc() fail, I doubt b->storage should get a non-zero value as the there is no storage available.

The fix do the check for a null. You can see this under the review conversation.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not understand your comment. I see the addition of if(b->buffer) in your patch, but fail to see how this properly handle the case where malloc() return NULL, as it seem incomplete and returning a misleading state from the oggpack_writeinit() method. Why is your edition still modifying b->storage if there is no memory area pointed to by b->buffer?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created https://gitlab.xiph.org/xiph/ogg/-/merge_requests/26 with my proposed fix for the same issue, including updating the documentation to mention that the method can fail.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not understand your comment. I see the addition of if(b->buffer) in your patch, but fail to see how this properly handle the case where malloc() return NULL

Conditional operator if (b->buffer) prevents from writing '\0' into b->buffer when it is null.

but fail to see how this properly handle the case where malloc() return NULL, as it seem incomplete and returning a misleading state from the oggpack_writeinit() method.

The commit do exactly what it says - nothing more, nothing less.
I could add another commit to address this exact issue (the incomplete state).

Why is your edition still modifying b->storage if there is no memory area pointed to by b->buffer?

That was in original code.

if(b->buffer) b->buffer[0]='\0';
b->storage=BUFFER_INCREMENT;
}

Expand Down
8 changes: 4 additions & 4 deletions src/framing.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}


Expand Down