pipebuffer: handle possible null pointer dereference

reported by clang static analyzer
This commit is contained in:
Zack Rusin
2009-06-20 21:36:40 -04:00
parent f311893bf4
commit 5920b6b679
2 changed files with 4 additions and 0 deletions
@@ -53,6 +53,8 @@ static INLINE struct malloc_buffer *
malloc_buffer(struct pb_buffer *buf)
{
assert(buf);
if (!buf)
return NULL;
assert(buf->vtbl == &malloc_buffer_vtbl);
return (struct malloc_buffer *)buf;
}
@@ -74,6 +74,8 @@ static INLINE struct pb_ondemand_buffer *
pb_ondemand_buffer(struct pb_buffer *buf)
{
assert(buf);
if (!buf)
return NULL;
assert(buf->vtbl == &pb_ondemand_buffer_vtbl);
return (struct pb_ondemand_buffer *)buf;
}