[Swfed-svn] swfed-svn [559] getTagData のメモリリークを修正

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2011年 4月 8日 (金) 17:57:06 JST


Revision: 559
          http://sourceforge.jp/projects/swfed/svn/view?view=rev&revision=559
Author:   yoya
Date:     2011-04-08 17:57:06 +0900 (Fri, 08 Apr 2011)

Log Message:
-----------
getTagData のメモリリークを修正

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


-------------- next part --------------
Modified: trunk/src/php_swfed.c
===================================================================
--- trunk/src/php_swfed.c	2011-04-08 08:48:46 UTC (rev 558)
+++ trunk/src/php_swfed.c	2011-04-08 08:57:06 UTC (rev 559)
@@ -588,19 +588,22 @@
 PHP_METHOD(swfed, getTagData) {
     long tag_seqno = 0;
     swf_object_t *swf = NULL;
-    unsigned char *data_ref = NULL;
+    unsigned char *data = NULL, *new_buff;
     unsigned long data_len = 0;
     
     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &tag_seqno) == FAILURE) {
         RETURN_FALSE;
     }
     swf = get_swf_object(getThis() TSRMLS_CC);
-    data_ref = swf_object_get_tagdata(swf, tag_seqno, &data_len);
-    if (data_ref == NULL) {
+    data = swf_object_get_tagdata(swf, tag_seqno, &data_len);
+    if (data == NULL) {
         fprintf(stderr, "getTagData: Can't get_tagdata\n");
         RETURN_FALSE;
     }
-    RETURN_STRINGL(data_ref, data_len, 1);
+    new_buff = emalloc(data_len);
+    memcpy(new_buff, data, data_len);
+    free(data);
+    RETURN_STRINGL(new_buff, data_len, 0);
 }
 
 PHP_METHOD(swfed, replaceTagData) {



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