Make opus_repacketizer_create handle malloc failure gracefully.
authorGregory Maxwell <greg@xiph.org>
Sun, 9 Oct 2011 22:08:06 +0000 (18:08 -0400)
committerJean-Marc Valin <jmvalin@jmvalin.ca>
Mon, 10 Oct 2011 00:28:51 +0000 (20:28 -0400)
src/repacketizer.c

index 7ee0e49..41eee6d 100644 (file)
@@ -56,7 +56,10 @@ OpusRepacketizer *opus_repacketizer_init(OpusRepacketizer *rp)
 
 OpusRepacketizer *opus_repacketizer_create(void)
 {
-   return opus_repacketizer_init((OpusRepacketizer *)opus_alloc(opus_repacketizer_get_size()));
+   OpusRepacketizer *rp;
+   rp=(OpusRepacketizer *)opus_alloc(opus_repacketizer_get_size());
+   if(rp==NULL)return NULL;
+   return opus_repacketizer_init(rp);
 }
 
 void opus_repacketizer_destroy(OpusRepacketizer *rp)