Skip to content

Commit a508349

Browse files
committed
Check for exception
1 parent 347ad41 commit a508349

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

ext/gmp/gmp.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,12 @@ static int gmp_compare(zval *op1, zval *op2) /* {{{ */
429429
zval result;
430430

431431
gmp_cmp(&result, op1, op2);
432+
433+
/* An error/exception occurs if one of the operands is not a numeric string
434+
* or an object which is different from GMP */
435+
if (EG(exception)) {
436+
return 1;
437+
}
432438
/* result can only be a zend_long if gmp_cmp hasn't thrown an Error */
433439
return Z_LVAL(result);
434440
}

ext/gmp/tests/comparison_invalid.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
--TEST--
2-
Overloaded GMP comparison in sort() etc
2+
Invalid comparison with a GMP object
33
--SKIPIF--
44
<?php if (!extension_loaded("gmp")) print "skip"; ?>
55
--FILE--

0 commit comments

Comments
 (0)