@@ -654,7 +654,7 @@ static void v8js_compile_script(zval *this_ptr, const zend_string *str, const ze
654
654
return ;
655
655
}
656
656
657
- static void v8js_execute_script (zval *this_ptr, v8js_script *res, long flags, long time_limit, long memory_limit, zval **return_value)
657
+ static void v8js_execute_script (zval *this_ptr, v8js_script *res, long flags, long time_limit, size_t memory_limit, zval **return_value)
658
658
{
659
659
v8js_ctx *c = Z_V8JS_CTX_OBJ_P (this_ptr);
660
660
@@ -702,13 +702,19 @@ static PHP_METHOD(V8Js, executeString)
702
702
return ;
703
703
}
704
704
705
+ if (memory_limit < 0 ) {
706
+ zend_throw_exception (php_ce_v8js_exception,
707
+ " memory_limit must not be negative" , 0 );
708
+ return ;
709
+ }
710
+
705
711
v8js_compile_script (getThis (), str, identifier, &res);
706
712
if (!res) {
707
713
RETURN_FALSE;
708
714
}
709
715
710
716
zend_try {
711
- v8js_execute_script (getThis (), res, flags, time_limit, memory_limit, &return_value);
717
+ v8js_execute_script (getThis (), res, flags, time_limit, static_cast < size_t >( memory_limit) , &return_value);
712
718
v8js_script_free (res);
713
719
}
714
720
zend_catch {
@@ -757,11 +763,17 @@ static PHP_METHOD(V8Js, executeScript)
757
763
return ;
758
764
}
759
765
766
+ if (memory_limit < 0 ) {
767
+ zend_throw_exception (php_ce_v8js_exception,
768
+ " memory_limit must not be negative" , 0 );
769
+ return ;
770
+ }
771
+
760
772
if ((res = (v8js_script *)zend_fetch_resource (Z_RES_P (zscript), PHP_V8JS_SCRIPT_RES_NAME, le_v8js_script)) == NULL ) {
761
773
RETURN_FALSE;
762
774
}
763
775
764
- v8js_execute_script (getThis (), res, flags, time_limit, memory_limit, &return_value);
776
+ v8js_execute_script (getThis (), res, flags, time_limit, static_cast < size_t >( memory_limit) , &return_value);
765
777
}
766
778
/* }}} */
767
779
@@ -907,14 +919,20 @@ static PHP_METHOD(V8Js, setMemoryLimit)
907
919
return ;
908
920
}
909
921
922
+ if (memory_limit < 0 ) {
923
+ zend_throw_exception (php_ce_v8js_exception,
924
+ " memory_limit must not be negative" , 0 );
925
+ return ;
926
+ }
927
+
910
928
c = Z_V8JS_CTX_OBJ_P (getThis ());
911
- c->memory_limit = memory_limit;
929
+ c->memory_limit = static_cast < size_t >( memory_limit) ;
912
930
913
931
V8JSG (timer_mutex).lock ();
914
932
for (std::deque< v8js_timer_ctx* >::iterator it = V8JSG (timer_stack).begin ();
915
933
it != V8JSG (timer_stack).end (); it ++) {
916
934
if ((*it)->ctx == c && !(*it)->killed ) {
917
- (*it)->memory_limit = memory_limit;
935
+ (*it)->memory_limit = static_cast < size_t >( memory_limit) ;
918
936
}
919
937
}
920
938
V8JSG (timer_mutex).unlock ();
0 commit comments