Skip to content

Commit f35ee01

Browse files
petterreinholdtsensezero
authored andcommitted
Adjusted oggpack_writeinit() to not crash if malloc() return NULL.
Inspired by proposal in xiph#91. (cherry picked from commit 8f30730)
1 parent d4e3d4e commit f35ee01

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

doc/libogg/oggpack_writeinit.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ <h3>Parameters</h3>
3939

4040
<h3>Return Values</h3>
4141
<blockquote>
42-
<li>
43-
No values are returned.</li>
42+
<p>No values are returned. If initialization fail, the buffer is
43+
unusable and calls to
44+
<a href="oggpack_writecheck.html">oggpack_writecheck()</a> will
45+
report the error.</p>
4446
</blockquote>
4547
<p>
4648

src/bitwise.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ static const unsigned int mask8B[]=
3939
void oggpack_writeinit(oggpack_buffer *b){
4040
memset(b,0,sizeof(*b));
4141
b->ptr=b->buffer=_ogg_malloc(BUFFER_INCREMENT);
42+
if (!b->buffer)
43+
return;
4244
b->buffer[0]='\0';
4345
b->storage=BUFFER_INCREMENT;
4446
}

0 commit comments

Comments
 (0)