@@ -240,6 +240,7 @@ static void proc_open_rsrc_dtor(zend_resource *rsrc)
240
240
FG (pclose_ret ) = -1 ;
241
241
#endif
242
242
_php_free_envp (proc -> env , proc -> is_persistent );
243
+ pefree (proc -> pipes , proc -> is_persistent );
243
244
pefree (proc -> command , proc -> is_persistent );
244
245
pefree (proc , proc -> is_persistent );
245
246
@@ -434,7 +435,8 @@ PHP_FUNCTION(proc_open)
434
435
zval * descitem = NULL ;
435
436
zend_string * str_index ;
436
437
zend_ulong nindex ;
437
- struct php_proc_open_descriptor_item descriptors [PHP_PROC_OPEN_MAX_DESCRIPTORS ];
438
+ struct php_proc_open_descriptor_item * descriptors = NULL ;
439
+ int ndescriptors_array ;
438
440
#ifdef PHP_WIN32
439
441
PROCESS_INFORMATION pi ;
440
442
HANDLE childHandle ;
@@ -499,7 +501,11 @@ PHP_FUNCTION(proc_open)
499
501
memset (& env , 0 , sizeof (env ));
500
502
}
501
503
502
- memset (descriptors , 0 , sizeof (descriptors ));
504
+ ndescriptors_array = zend_hash_num_elements (Z_ARRVAL_P (descriptorspec ));
505
+
506
+ descriptors = safe_emalloc (sizeof (struct php_proc_open_descriptor_item ), ndescriptors_array , 0 );
507
+
508
+ memset (descriptors , 0 , sizeof (struct php_proc_open_descriptor_item ) * ndescriptors_array );
503
509
504
510
#ifdef PHP_WIN32
505
511
/* we use this to allow the child to inherit handles */
@@ -669,9 +675,7 @@ PHP_FUNCTION(proc_open)
669
675
goto exit_fail ;
670
676
}
671
677
}
672
-
673
- if (++ ndesc == PHP_PROC_OPEN_MAX_DESCRIPTORS )
674
- break ;
678
+ ndesc ++ ;
675
679
} ZEND_HASH_FOREACH_END ();
676
680
677
681
#ifdef PHP_WIN32
@@ -875,6 +879,7 @@ PHP_FUNCTION(proc_open)
875
879
proc = (struct php_process_handle * )pemalloc (sizeof (struct php_process_handle ), is_persistent );
876
880
proc -> is_persistent = is_persistent ;
877
881
proc -> command = command ;
882
+ proc -> pipes = pemalloc (sizeof (zend_resource * ) * ndesc , is_persistent );
878
883
proc -> npipes = ndesc ;
879
884
proc -> child = child ;
880
885
#ifdef PHP_WIN32
@@ -952,10 +957,12 @@ PHP_FUNCTION(proc_open)
952
957
}
953
958
}
954
959
960
+ efree (descriptors );
955
961
ZVAL_RES (return_value , zend_register_resource (proc , le_proc_open ));
956
962
return ;
957
963
958
964
exit_fail :
965
+ efree (descriptors );
959
966
_php_free_envp (env , is_persistent );
960
967
pefree (command , is_persistent );
961
968
#if PHP_CAN_DO_PTS
0 commit comments