Skip to content

Commit

Permalink
修复可能存在的内存泄漏
Browse files Browse the repository at this point in the history
如题
  • Loading branch information
toxmc committed Apr 15, 2016
1 parent a40f67a commit 55896d6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions book/sample/chapt11/11-02-00-tipi-hello-world/tipi_demo01.c
Expand Up @@ -83,15 +83,16 @@ PHP_FUNCTION(tipi_hello_world)
char *result = NULL;
char *prefix = "hello world, ";


if (zend_parse_parameters(argc TSRMLS_CC, "s", &name, &name_len) == FAILURE)
return;

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

RETURN_STRING(result);
ZVAL_STRING(return_value, result);
efree(result);
return;
}
/* }}} */

Expand Down

0 comments on commit 55896d6

Please sign in to comment.