[xiph-commits] r3821 - in liboggz/trunk: include/oggz src/liboggz

conrad at svn.annodex.net conrad at svn.annodex.net
Sun Dec 7 22:41:25 PST 2008


Author: conrad
Date: 2008-12-07 22:41:24 -0800 (Sun, 07 Dec 2008)
New Revision: 3821

Modified:
   liboggz/trunk/include/oggz/oggz_comments.h
   liboggz/trunk/include/oggz/oggz_read.h
   liboggz/trunk/src/liboggz/oggz.c
   liboggz/trunk/src/liboggz/oggz_comments.c
   liboggz/trunk/src/liboggz/oggz_read.c
   liboggz/trunk/src/liboggz/oggz_write.c
Log:
liboggz: handle out of memory on return from internal functions oggz_stream_add(), oggz_comments_init() throughout


Modified: liboggz/trunk/include/oggz/oggz_comments.h
===================================================================
--- liboggz/trunk/include/oggz/oggz_comments.h	2008-12-08 05:56:45 UTC (rev 3820)
+++ liboggz/trunk/include/oggz/oggz_comments.h	2008-12-08 06:41:24 UTC (rev 3821)
@@ -120,6 +120,7 @@
  * \retval 0 Success
  * \retval OGGZ_ERR_BAD \a oggz is not a valid OGGZ* handle
  * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ
+ * \retval OGGZ_ERR_OUT_OF_MEMORY Out of memory
  * \note The vendor string should identify the library used to produce
  * the stream, e.g. libvorbis 1.0 used "Xiph.Org libVorbis I 20020717".
  * If copying a bitstream it should be the same as the source.
@@ -190,6 +191,7 @@
  * \retval 0 Success
  * \retval OGGZ_ERR_BAD \a oggz is not a valid OGGZ* handle
  * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ
+ * \retval OGGZ_ERR_OUT_OF_MEMORY Out of memory
  */
 int
 oggz_comment_add (OGGZ * oggz, long serialno, OggzComment * comment);
@@ -203,6 +205,7 @@
  * \retval 0 Success
  * \retval OGGZ_ERR_BAD \a oggz is not a valid OGGZ* handle
  * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ
+ * \retval OGGZ_ERR_OUT_OF_MEMORY Out of memory
  */
 int
 oggz_comment_add_byname (OGGZ * oggz, long serialno,

Modified: liboggz/trunk/include/oggz/oggz_read.h
===================================================================
--- liboggz/trunk/include/oggz/oggz_read.h	2008-12-08 05:56:45 UTC (rev 3820)
+++ liboggz/trunk/include/oggz/oggz_read.h	2008-12-08 06:41:24 UTC (rev 3821)
@@ -94,6 +94,7 @@
  * logical bitstream in \a oggz.
  * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ
  * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ
+ * \retval OGGZ_ERR_OUT_OF_MEMORY Out of memory
  *
  * \note Values of \a serialno other than -1 allows you to specify different
  * callback functions for each logical bitstream.
@@ -131,6 +132,7 @@
  * \retval 0 Success
  * \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ
  * \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ
+ * \retval OGGZ_ERR_OUT_OF_MEMORY Out of memory
  *
  * \note Values of \a serialno other than -1 allows you to specify different
  * callback functions for each logical bitstream.
@@ -156,6 +158,7 @@
  * returning OGGZ_STOP_OK
  * \retval OGGZ_ERR_STOP_ERR Reading was stopped by a user callback
  * returning OGGZ_STOP_ERR
+ * \retval OGGZ_ERR_OUT_OF_MEMORY Out of memory
  */
 long oggz_read (OGGZ * oggz, long n);
 

Modified: liboggz/trunk/src/liboggz/oggz.c
===================================================================
--- liboggz/trunk/src/liboggz/oggz.c	2008-12-08 05:56:45 UTC (rev 3820)
+++ liboggz/trunk/src/liboggz/oggz.c	2008-12-08 06:41:24 UTC (rev 3821)
@@ -337,7 +337,10 @@
 
   ogg_stream_init (&stream->ogg_stream, (int)serialno);
 
-  oggz_comments_init (stream);
+  if (oggz_comments_init (stream) == -1) {
+    oggz_free (stream);
+    return NULL;
+  }
 
   stream->content = OGGZ_CONTENT_UNKNOWN;
   stream->numheaders = 3; /* Default to 3 headers for Ogg logical bitstreams */

Modified: liboggz/trunk/src/liboggz/oggz_comments.c
===================================================================
--- liboggz/trunk/src/liboggz/oggz_comments.c	2008-12-08 05:56:45 UTC (rev 3820)
+++ liboggz/trunk/src/liboggz/oggz_comments.c	2008-12-08 06:41:24 UTC (rev 3821)
@@ -225,7 +225,10 @@
   if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ;
 
   stream = oggz_get_stream (oggz, serialno);
-  if (stream == NULL) stream = oggz_add_stream (oggz, serialno);
+  if (stream == NULL)
+    stream = oggz_add_stream (oggz, serialno);
+  if (stream == NULL)
+    return OGGZ_ERR_OUT_OF_MEMORY;
 
   if (oggz->flags & OGGZ_WRITE) {
     if (OGGZ_CONFIG_WRITE) {
@@ -331,7 +334,10 @@
   if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ;
 
   stream = oggz_get_stream (oggz, serialno);
-  if (stream == NULL) stream = oggz_add_stream (oggz, serialno);
+  if (stream == NULL)
+    stream = oggz_add_stream (oggz, serialno);
+  if (stream == NULL)
+    return OGGZ_ERR_OUT_OF_MEMORY;
 
   if (oggz->flags & OGGZ_WRITE) {
     if (OGGZ_CONFIG_WRITE) {
@@ -362,7 +368,10 @@
   if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ;
 
   stream = oggz_get_stream (oggz, serialno);
-  if (stream == NULL) stream = oggz_add_stream (oggz, serialno);
+  if (stream == NULL)
+    stream = oggz_add_stream (oggz, serialno);
+  if (stream == NULL)
+    return OGGZ_ERR_OUT_OF_MEMORY;
 
   if (oggz->flags & OGGZ_WRITE) {
     if (OGGZ_CONFIG_WRITE) {
@@ -477,6 +486,8 @@
 {
   stream->vendor = NULL;
   stream->comments = oggz_vector_new ();
+  if (stream->comments == NULL) return -1;
+
   oggz_vector_set_cmp (stream->comments, (OggzCmpFunc) oggz_comment_cmp, NULL);
 
   return 0;

Modified: liboggz/trunk/src/liboggz/oggz_read.c
===================================================================
--- liboggz/trunk/src/liboggz/oggz_read.c	2008-12-08 05:56:45 UTC (rev 3820)
+++ liboggz/trunk/src/liboggz/oggz_read.c	2008-12-08 06:41:24 UTC (rev 3821)
@@ -122,6 +122,8 @@
     stream = oggz_get_stream (oggz, serialno);
     if (stream == NULL)
       stream = oggz_add_stream (oggz, serialno);
+    if (stream == NULL)
+      return OGGZ_ERR_OUT_OF_MEMORY;
 
     stream->read_packet = read_packet;
     stream->read_user_data = user_data;
@@ -152,6 +154,8 @@
     stream = oggz_get_stream (oggz, serialno);
     if (stream == NULL)
       stream = oggz_add_stream (oggz, serialno);
+    if (stream == NULL)
+      return OGGZ_ERR_OUT_OF_MEMORY;
 
     stream->read_page = read_page;
     stream->read_page_user_data = user_data;
@@ -341,7 +345,7 @@
           /* new stream ... check bos etc. */
           if ((stream = oggz_add_stream (oggz, serialno)) == NULL) {
             /* error -- could not add stream */
-            return -7;
+            return OGGZ_ERR_OUT_OF_MEMORY;
           }
         }
         os = &stream->ogg_stream;
@@ -499,7 +503,7 @@
       /* new stream ... check bos etc. */
       if ((stream = oggz_add_stream (oggz, serialno)) == NULL) {
         /* error -- could not add stream */
-        return -7;
+        return OGGZ_ERR_OUT_OF_MEMORY;
       }
 
       /* identify stream type */
@@ -568,6 +572,8 @@
   reader = &oggz->x.reader;
 
   cb_ret = oggz_read_sync (oggz);
+  if (cb_ret == OGGZ_ERR_OUT_OF_MEMORY)
+    return cb_ret;
 
   while (cb_ret != OGGZ_STOP_ERR && cb_ret != OGGZ_STOP_OK &&
          bytes_read > 0 && remaining > 0) {
@@ -585,6 +591,8 @@
       nread += bytes_read;
       
       cb_ret = oggz_read_sync (oggz);
+      if (cb_ret == OGGZ_ERR_OUT_OF_MEMORY)
+        return cb_ret;
     }
   }
 
@@ -636,6 +644,8 @@
   reader = &oggz->x.reader;
 
   cb_ret = oggz_read_sync (oggz);
+  if (cb_ret == OGGZ_ERR_OUT_OF_MEMORY)
+    return cb_ret;
 
   while (cb_ret != OGGZ_STOP_ERR && cb_ret != OGGZ_STOP_OK  &&
          /* !oggz->eos && */ remaining > 0) {
@@ -649,6 +659,8 @@
     nread += bytes;
 
     cb_ret = oggz_read_sync (oggz);
+    if (cb_ret == OGGZ_ERR_OUT_OF_MEMORY)
+      return cb_ret;
   }
 
   if (cb_ret == OGGZ_STOP_ERR) oggz_purge (oggz);

Modified: liboggz/trunk/src/liboggz/oggz_write.c
===================================================================
--- liboggz/trunk/src/liboggz/oggz_write.c	2008-12-08 05:56:45 UTC (rev 3820)
+++ liboggz/trunk/src/liboggz/oggz_write.c	2008-12-08 06:41:24 UTC (rev 3821)
@@ -257,6 +257,8 @@
 
     if (b_o_s || !strict || suffix) {
       stream = oggz_add_stream (oggz, serialno);
+      if (stream == NULL)
+        return OGGZ_ERR_OUT_OF_MEMORY;
       oggz_auto_identify_packet (oggz, op, serialno);
     } else {
       return OGGZ_ERR_BAD_SERIALNO;



More information about the commits mailing list