Skip to content

Commit ad1b890

Browse files
committed
PHPC-1472: Prevent multiple exceptions from being thrown while dumping manager
1 parent 0cee163 commit ad1b890

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/MongoDB/Manager.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,13 @@ static HashTable* php_phongo_manager_get_debug_info(zval* object, int* is_temp T
893893
for (i = 0; i < n; i++) {
894894
zval obj;
895895

896-
php_phongo_server_to_zval(&obj, sds[i]);
896+
if (!php_phongo_server_to_zval(&obj, sds[i])) {
897+
/* Exception already thrown */
898+
zval_ptr_dtor(&obj);
899+
zval_ptr_dtor(&cluster);
900+
goto done;
901+
}
902+
897903
add_next_index_zval(&cluster, &obj);
898904
}
899905

@@ -906,13 +912,20 @@ static HashTable* php_phongo_manager_get_debug_info(zval* object, int* is_temp T
906912
zval* obj = NULL;
907913

908914
MAKE_STD_ZVAL(obj);
909-
php_phongo_server_to_zval(obj, sds[i]);
915+
if (!php_phongo_server_to_zval(obj, sds[i])) {
916+
/* Exception already thrown */
917+
zval_ptr_dtor(&obj);
918+
zval_ptr_dtor(&cluster);
919+
goto done;
920+
}
921+
910922
add_next_index_zval(cluster, obj);
911923
}
912924

913925
ADD_ASSOC_ZVAL_EX(&retval, "cluster", cluster);
914926
#endif
915927

928+
done:
916929
mongoc_server_descriptions_destroy_all(sds, n);
917930

918931
return Z_ARRVAL(retval);

0 commit comments

Comments
 (0)