Skip to content

Commit

Permalink
Merge pull request #31 from mgdm/fix-miss-free
Browse files Browse the repository at this point in the history
Attempt to fix a warning on Travis-CI
  • Loading branch information
mgdm committed Sep 2, 2015
2 parents c1fd3ea + 6aae69f commit f7deb70
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions mosquitto.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ PHP_METHOD(Mosquitto_Client, __construct)
if (!object->client) {
char *message = php_mosquitto_strerror_wrapper(errno);
zend_throw_exception(mosquitto_ce_exception, message, 1 TSRMLS_CC);
efree(message);
#ifndef STRERROR_R_CHAR_P
if (message != NULL) {
efree(message);
}
#endif
}
}
/* }}} */
Expand Down Expand Up @@ -835,10 +839,11 @@ static int strerror_r(int errnum, char *buf, size_t buf_len)

PHP_MOSQUITTO_API char *php_mosquitto_strerror_wrapper(int err)
{
char *buf = ecalloc(256, sizeof(char));
char *buf;
#ifdef STRERROR_R_CHAR_P
return strerror_r(err, buf, 256);
#else
buf = ecalloc(256, sizeof(char));
if (!strerror_r(err, buf, 256)) {
return buf;
}
Expand Down
2 changes: 1 addition & 1 deletion travis/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ cd tests
mosquitto -c mosquitto.conf -d
cd ..

REPORT_EXIT_STATUS=1 TEST_PHP_ARGS="-q --show-diff" make test
USE_ZEND_ALLOC=1 REPORT_EXIT_STATUS=1 TEST_PHP_ARGS="-q --show-diff" make test

0 comments on commit f7deb70

Please sign in to comment.