[Swfed-svn] swfed-svn [557] malloc 失敗時のエラー処理を追加

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2011年 4月 8日 (金) 16:54:33 JST


Revision: 557
          http://sourceforge.jp/projects/swfed/svn/view?view=rev&revision=557
Author:   yoya
Date:     2011-04-08 16:54:32 +0900 (Fri, 08 Apr 2011)

Log Message:
-----------
malloc 失敗時のエラー処理を追加

Modified Paths:
--------------
    trunk/src/bitstream.c


-------------- next part --------------
Modified: trunk/src/bitstream.c
===================================================================
--- trunk/src/bitstream.c	2011-04-08 05:26:47 UTC (rev 556)
+++ trunk/src/bitstream.c	2011-04-08 07:54:32 UTC (rev 557)
@@ -67,6 +67,12 @@
     bitstream_clear(bs);
     bs->data_alloc_len = data_len;
     bs->data = malloc(bs->data_alloc_len);
+    if (bs->data == NULL) {
+        fprintf(stderr, "bitstream_input: malloc failed\n");
+        bs->data_alloc_len = 0;
+        bs->data_len = 0;
+        return 1;
+    }
     memcpy(bs->data, data, data_len);
     bs->data_len = data_len;
     return 0;



Swfed-svn メーリングリストの案内
Back to archive index