@@ -451,12 +451,14 @@ mongoc_bulk_operation_t *phongo_bulkwrite_init(zend_bool ordered) { /* {{{ */
451
451
#define PHONGO_WRITECONCERN_ALLOWED 0x01
452
452
#define PHONGO_READPREFERENCE_ALLOWED 0x02
453
453
454
- static int process_read_concern (zval * option , bson_t * mongoc_opts TSRMLS_DC )
454
+ static bool process_read_concern (zval * option , bson_t * mongoc_opts TSRMLS_DC )
455
455
{
456
456
if (Z_TYPE_P (option ) == IS_OBJECT && instanceof_function (Z_OBJCE_P (option ), php_phongo_readconcern_ce TSRMLS_CC )) {
457
457
const mongoc_read_concern_t * read_concern = phongo_read_concern_from_zval (option TSRMLS_CC );
458
458
459
- mongoc_read_concern_append ((mongoc_read_concern_t * )read_concern , mongoc_opts );
459
+ if (!mongoc_read_concern_append ((mongoc_read_concern_t * )read_concern , mongoc_opts )) {
460
+ phongo_throw_exception (PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC , "Error appending \"%s\" option" , "ReadPreference" );
461
+ }
460
462
} else {
461
463
phongo_throw_exception (
462
464
PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC ,
@@ -497,7 +499,7 @@ static int phongo_do_select_server(mongoc_client_t *client, bson_t *opts, zval *
497
499
return selected_server_id ;
498
500
}
499
501
500
- static int process_read_preference (zval * option , bson_t * mongoc_opts , zval * * zreadPreference , mongoc_client_t * client , int server_id TSRMLS_DC )
502
+ static bool process_read_preference (zval * option , bson_t * mongoc_opts , zval * * zreadPreference , mongoc_client_t * client , int server_id TSRMLS_DC )
501
503
{
502
504
if (Z_TYPE_P (option ) == IS_OBJECT && instanceof_function (Z_OBJCE_P (option ), php_phongo_readpreference_ce TSRMLS_CC )) {
503
505
int selected_server_id ;
@@ -519,14 +521,16 @@ static int process_read_preference(zval *option, bson_t *mongoc_opts, zval **zre
519
521
return true;
520
522
}
521
523
522
- static int process_write_concern (zval * option , bson_t * mongoc_opts , zval * * zwriteConcern TSRMLS_DC )
524
+ static bool process_write_concern (zval * option , bson_t * mongoc_opts , zval * * zwriteConcern TSRMLS_DC )
523
525
{
524
526
if (Z_TYPE_P (option ) == IS_OBJECT && instanceof_function (Z_OBJCE_P (option ), php_phongo_writeconcern_ce TSRMLS_CC )) {
525
527
const mongoc_write_concern_t * write_concern = phongo_write_concern_from_zval (option TSRMLS_CC );
526
528
527
529
* zwriteConcern = option ;
528
530
529
- mongoc_write_concern_append ((mongoc_write_concern_t * ) write_concern , mongoc_opts );
531
+ if (!mongoc_write_concern_append ((mongoc_write_concern_t * ) write_concern , mongoc_opts )) {
532
+ phongo_throw_exception (PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC , "Error appending \"%s\" option" , "WriteConcern" );
533
+ }
530
534
} else {
531
535
phongo_throw_exception (
532
536
PHONGO_ERROR_INVALID_ARGUMENT TSRMLS_CC ,
@@ -830,6 +834,8 @@ int phongo_execute_command(mongoc_client_t *client, php_phongo_command_type_t ty
830
834
default :
831
835
/* Should never happen, but if it does: exception */
832
836
phongo_throw_exception (PHONGO_ERROR_LOGIC TSRMLS_CC , "Type '%d' should never have been passed to phongo_execute_command, please file a bug report" , type );
837
+ bson_free (opts );
838
+ return false;
833
839
}
834
840
if (!result ) {
835
841
phongo_throw_exception_from_bson_error_t (& error TSRMLS_CC );
0 commit comments