Skip to content

PHPC-736: Remove zend_str_tolower_dup() in ObjectID construction #543

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 6, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions src/BSON/ObjectID.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,20 @@ static bool php_phongo_objectid_init(php_phongo_objectid_t *intern)

/* Initialize the object from a hex string and return whether it was successful.
* An exception will be thrown on error. */
static bool php_phongo_objectid_init_from_hex_string(php_phongo_objectid_t *intern, const char *oid, phongo_zpp_char_len oid_len TSRMLS_DC)
static bool php_phongo_objectid_init_from_hex_string(php_phongo_objectid_t *intern, const char *hex, phongo_zpp_char_len hex_len TSRMLS_DC)
{
char *tid = zend_str_tolower_dup(oid, oid_len);

if (bson_oid_is_valid(tid, oid_len)) {
if (bson_oid_is_valid(hex, hex_len)) {
bson_oid_t oid;

bson_oid_init_from_string(&oid, tid);
bson_oid_init_from_string(&oid, hex);
bson_oid_to_string(&oid, intern->oid);
intern->initialized = true;

efree(tid);
return true;
}

phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Error parsing ObjectID string: %s", oid);
phongo_throw_exception(PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC, "Error parsing ObjectID string: %s", hex);

efree(tid);
return false;
}

Expand Down