Skip to content

Commit ab538a4

Browse files
committed
ZendMM can't fail, omit checks
1 parent 79cabcd commit ab538a4

File tree

2 files changed

+0
-39
lines changed

2 files changed

+0
-39
lines changed

ext/odbc/php_odbc.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2183,47 +2183,27 @@ int odbc_sqlconnect(odbc_connection **conn, char *db, char *uid, char *pwd, int
21832183
char *uid_quoted = NULL, *pwd_quoted = NULL;
21842184
bool should_quote_uid = !php_odbc_connstr_is_quoted(uid) && php_odbc_connstr_should_quote(uid);
21852185
bool should_quote_pwd = !php_odbc_connstr_is_quoted(pwd) && php_odbc_connstr_should_quote(pwd);
2186-
bool connection_string_fail = false;
21872186
if (should_quote_uid) {
21882187
size_t estimated_length = php_odbc_connstr_estimate_quote_length(uid);
21892188
uid_quoted = emalloc(estimated_length);
2190-
if (!uid_quoted) {
2191-
connection_string_fail = true;
2192-
goto connection_string_fail;
2193-
}
21942189
php_odbc_connstr_quote(uid_quoted, uid, estimated_length);
21952190
} else {
21962191
uid_quoted = uid;
21972192
}
21982193
if (should_quote_pwd) {
21992194
size_t estimated_length = php_odbc_connstr_estimate_quote_length(pwd);
22002195
pwd_quoted = emalloc(estimated_length);
2201-
if (!pwd_quoted) {
2202-
connection_string_fail = true;
2203-
goto connection_string_fail;
2204-
}
22052196
php_odbc_connstr_quote(pwd_quoted, pwd, estimated_length);
22062197
} else {
22072198
pwd_quoted = pwd;
22082199
}
22092200
spprintf(&ldb, 0, "%s;UID=%s;PWD=%s", db, uid_quoted, pwd_quoted);
2210-
connection_string_fail:
22112201
if (uid_quoted && should_quote_uid) {
22122202
efree(uid_quoted);
22132203
}
22142204
if (pwd_quoted && should_quote_pwd) {
22152205
efree(pwd_quoted);
22162206
}
2217-
/*
2218-
* In the PDO version, we fail, but we don't
2219-
* really have the facility for that, so fall
2220-
* back to the old unquoted case. Note that
2221-
* the success case hasn't been allocated, so
2222-
* it should be safe.
2223-
*/
2224-
if (connection_string_fail) {
2225-
spprintf(&ldb, 0, "%s;UID=%s;PWD=%s", db, uid, pwd);
2226-
}
22272207
} else {
22282208
ldb_len = strlen(db)+1;
22292209
ldb = (char*) emalloc(ldb_len);

ext/pdo_odbc/odbc_driver.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -497,25 +497,16 @@ static int pdo_odbc_handle_factory(pdo_dbh_t *dbh, zval *driver_options) /* {{{
497497
char *uid = NULL, *pwd = NULL;
498498
bool should_quote_uid = !php_odbc_connstr_is_quoted(dbh->username) && php_odbc_connstr_should_quote(dbh->username);
499499
bool should_quote_pwd = !php_odbc_connstr_is_quoted(dbh->password) && php_odbc_connstr_should_quote(dbh->password);
500-
bool connection_string_fail = false;
501500
if (should_quote_uid) {
502501
size_t estimated_length = php_odbc_connstr_estimate_quote_length(dbh->username);
503502
uid = emalloc(estimated_length);
504-
if (!uid) {
505-
connection_string_fail = true;
506-
goto connection_string_fail;
507-
}
508503
php_odbc_connstr_quote(uid, dbh->username, estimated_length);
509504
} else {
510505
uid = dbh->username;
511506
}
512507
if (should_quote_pwd) {
513508
size_t estimated_length = php_odbc_connstr_estimate_quote_length(dbh->password);
514509
pwd = emalloc(estimated_length);
515-
if (!pwd) {
516-
connection_string_fail = true;
517-
goto connection_string_fail;
518-
}
519510
php_odbc_connstr_quote(pwd, dbh->password, estimated_length);
520511
} else {
521512
pwd = dbh->password;
@@ -524,25 +515,15 @@ static int pdo_odbc_handle_factory(pdo_dbh_t *dbh, zval *driver_options) /* {{{
524515
+ strlen(uid) + strlen(pwd)
525516
+ strlen(";UID=;PWD=") + 1;
526517
char *dsn = pemalloc(new_dsn_size, dbh->is_persistent);
527-
if (dsn == NULL) {
528-
connection_string_fail = true;
529-
/* XXX: Do we inform the caller? */
530-
goto connection_string_fail;
531-
}
532518
snprintf(dsn, new_dsn_size, "%s;UID=%s;PWD=%s", dbh->data_source, uid, pwd);
533519
pefree((char*)dbh->data_source, dbh->is_persistent);
534520
dbh->data_source = dsn;
535-
/* Convoluted label to handle freeing in this scope */
536-
connection_string_fail:
537521
if (uid && should_quote_uid) {
538522
efree(uid);
539523
}
540524
if (pwd && should_quote_pwd) {
541525
efree(pwd);
542526
}
543-
if (connection_string_fail) {
544-
goto fail;
545-
}
546527
}
547528

548529
rc = SQLDriverConnect(H->dbc, NULL, (SQLCHAR *) dbh->data_source, strlen(dbh->data_source),

0 commit comments

Comments
 (0)