Skip to content

Commit 55896d6

Browse files
committed
修复可能存在的内存泄漏
如题
1 parent a40f67a commit 55896d6

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

book/sample/chapt11/11-02-00-tipi-hello-world/tipi_demo01.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,16 @@ PHP_FUNCTION(tipi_hello_world)
8383
char *result = NULL;
8484
char *prefix = "hello world, ";
8585

86-
8786
if (zend_parse_parameters(argc TSRMLS_CC, "s", &name, &name_len) == FAILURE)
8887
return;
8988

9089
result = (char *) ecalloc(strlen(prefix) + name_len + 1, sizeof(char));
9190
strncat(result, prefix, strlen(prefix));
9291
strncat(result, name, name_len);
9392

94-
RETURN_STRING(result);
93+
ZVAL_STRING(return_value, result);
94+
efree(result);
95+
return;
9596
}
9697
/* }}} */
9798

0 commit comments

Comments
 (0)