Skip to content

Commit f76b706

Browse files
committed
Allow null arguments for ibase_service_attach()
1 parent 3eb5e4e commit f76b706

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

ibase_service.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,20 +210,21 @@ PHP_FUNCTION(ibase_delete_user)
210210
}
211211
/* }}} */
212212

213-
/* {{{ proto resource ibase_service_attach(string host, string dba_username, string dba_password)
213+
/* {{{ proto resource ibase_service_attach([string host [, string dba_username [, string dba_password]]])
214214
Connect to the service manager */
215215
PHP_FUNCTION(ibase_service_attach)
216216
{
217217
size_t hlen = 0, ulen = 0, plen = 0;
218218
ibase_service *svm;
219-
char buf[350], *host, *user, *pass;
219+
char *host = NULL, *user = NULL, *pass = NULL;
220+
char buf[350];
220221
char loc[128] = "service_mgr";
221222
isc_svc_handle handle = 0;
222223
unsigned short p = 0;
223224

224225
RESET_ERRMSG;
225226

226-
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "|sss",
227+
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "|s!s!s!",
227228
&host, &hlen, &user, &ulen, &pass, &plen)) {
228229

229230
RETURN_FALSE;
@@ -274,8 +275,8 @@ PHP_FUNCTION(ibase_service_attach)
274275

275276
svm = (ibase_service*)emalloc(sizeof(ibase_service));
276277
svm->handle = handle;
277-
svm->hostname = estrdup(host);
278-
svm->username = estrdup(user);
278+
svm->hostname = hlen > 0 ? estrdup(host) : NULL;
279+
svm->username = ulen > 0 ? estrdup(user) : NULL;
279280

280281
RETVAL_RES(zend_register_resource(svm, le_service));
281282
Z_TRY_ADDREF_P(return_value);

0 commit comments

Comments
 (0)