Skip to content

Commit

Permalink
Merge pull request #543
Browse files Browse the repository at this point in the history
  • Loading branch information
jmikola committed Mar 6, 2017
2 parents 17da705 + f2b4eb7 commit 353c78e
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/BSON/ObjectID.c
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

0 comments on commit 353c78e

Please sign in to comment.