From: Ilia Alshanetsky <iliaa@php.net>
Date: Thu, 18 Mar 2004 02:16:35 +0000 (+0000)
Subject: s/emalloc/safe_emalloc/ where appropriate.
X-Git-Tag: php-5.0.0RC1~15
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d0a480157966e0bc7579eb8963959f320f6a0ea4;p=php

s/emalloc/safe_emalloc/ where appropriate.
---

diff --git a/ext/com_dotnet/com_typeinfo.c b/ext/com_dotnet/com_typeinfo.c
index 98c0a2e843..ed521d1233 100644
--- a/ext/com_dotnet/com_typeinfo.c
+++ b/ext/com_dotnet/com_typeinfo.c
@@ -489,7 +489,7 @@ int php_com_process_typeinfo(ITypeInfo *typeinfo, HashTable *id_to_name, int pri
 					unsigned int funcdesclen, cnames = 0;
 					BSTR *names;
 
-					names = (BSTR*)emalloc((func->cParams + 1) * sizeof(BSTR));
+					names = (BSTR*)safe_emalloc((func->cParams + 1), sizeof(BSTR), 0);
 
 					ITypeInfo_GetNames(typeinfo, func->memid, names, func->cParams + 1, &cnames);
 					/* first element is the function name */
diff --git a/ext/com_dotnet/com_wrapper.c b/ext/com_dotnet/com_wrapper.c
index fc87f890ce..0ca3247a45 100644
--- a/ext/com_dotnet/com_wrapper.c
+++ b/ext/com_dotnet/com_wrapper.c
@@ -272,7 +272,7 @@ static HRESULT STDMETHODCALLTYPE disp_invokeex(
 		
 		/* convert args into zvals.
 		 * Args are in reverse order */
-		params = (zval ***)emalloc(sizeof(zval **) * pdp->cArgs);
+		params = (zval ***)safe_emalloc(sizeof(zval **), pdp->cArgs, 0);
 		for (i = 0; i < pdp->cArgs; i++) {
 			VARIANT *arg;
 			zval *zarg;
diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c
index 35ba391304..d3e2b31d19 100644
--- a/ext/soap/php_encoding.c
+++ b/ext/soap/php_encoding.c
@@ -1362,7 +1362,7 @@ static int* get_position_12(int dimension, const char* str)
 	int *pos;
 	int i = -1, flag = 0;
 
-	pos = emalloc(sizeof(int)*dimension);
+	pos = safe_emalloc(sizeof(int), dimension, 0);
 	memset(pos,0,sizeof(int)*dimension);
 	while (*str != '\0' && (*str < '0' || *str > '9') && (*str != '*')) {
 		str++;
@@ -1419,7 +1419,7 @@ static int* get_position(int dimension, const char* str)
 {
 	int *pos;
 
-	pos = emalloc(sizeof(int)*dimension);
+	pos = safe_emalloc(sizeof(int), dimension, 0);
 	get_position_ex(dimension, str, &pos);
 	return pos;
 }
@@ -1557,7 +1557,7 @@ static xmlNodePtr to_xml_array(encodeTypePtr type, zval *data, int style, xmlNod
 				smart_str_appends(&array_type, value);
 			}
 
-			dims = emalloc(sizeof(int)*dimension);
+			dims = safe_emalloc(sizeof(int), dimension, 0);
 			dims[0] = i;
 			el = &data;
 			for (i = 1; i < dimension; i++) {
@@ -1647,14 +1647,14 @@ static xmlNodePtr to_xml_array(encodeTypePtr type, zval *data, int style, xmlNod
 
 			smart_str_append_long(&array_size, i);
 
-			dims = emalloc(sizeof(int)*dimension);
+			dims = safe_emalloc(sizeof(int), dimension, 0);
 			dims[0] = i;
 		} else {
 
 			get_array_type(xmlParam, data, &array_type TSRMLS_CC);
 			enc = get_encoder_ex(SOAP_GLOBAL(sdl), array_type.c, array_type.len);
 			smart_str_append_long(&array_size, i);
-			dims = emalloc(sizeof(int)*dimension);
+			dims = safe_emalloc(sizeof(int), dimension, 0);
 			dims[0] = i;
 		}
 
@@ -1832,7 +1832,7 @@ static zval *to_zval_array(encodeTypePtr type, xmlNodePtr data)
 		dims = emalloc(sizeof(int));
 		*dims = 0;
 	}
-	pos = emalloc(sizeof(int)*dimension);
+	pos = safe_emalloc(sizeof(int), dimension, 0);
 	memset(pos,0,sizeof(int)*dimension);
 	if (data &&
 	    (attr = get_attribute(data->properties,"offset")) &&
diff --git a/ext/soap/soap.c b/ext/soap/soap.c
index dd312b22d3..5e39ade5ee 100644
--- a/ext/soap/soap.c
+++ b/ext/soap/soap.c
@@ -1002,7 +1002,7 @@ PHP_METHOD(soapserver,setclass)
 	FETCH_THIS_SERVICE(service);
 
 	argc = ZEND_NUM_ARGS();
-	argv = emalloc(argc * sizeof(zval **));
+	argv = safe_emalloc(argc, sizeof(zval **), 0);
 
 	if (argc < 1 || zend_get_parameters_array_ex(argc, argv) == FAILURE) {
 		efree(argv);
@@ -1025,7 +1025,7 @@ PHP_METHOD(soapserver,setclass)
 			service->soap_class.argc = argc - 1;
 			if (service->soap_class.argc > 0) {
 				int i;
-				service->soap_class.argv = emalloc(sizeof(zval) * service->soap_class.argc);
+				service->soap_class.argv = safe_emalloc(sizeof(zval), service->soap_class.argc, 0);
 				for (i = 0;i < service->soap_class.argc;i++) {
 					service->soap_class.argv[i] = *(argv[i + 1]);
 					zval_add_ref(&service->soap_class.argv[i]);
@@ -2069,7 +2069,7 @@ PHP_METHOD(soapclient, __call)
 
 	arg_count = zend_hash_num_elements(Z_ARRVAL_P(args));
 
-	real_args = emalloc(sizeof(zval *) * arg_count);
+	real_args = safe_emalloc(sizeof(zval *), arg_count, 0);
 	for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(args), &pos);
 		zend_hash_get_current_data_ex(Z_ARRVAL_P(args), (void **) &param, &pos) == SUCCESS;
 		zend_hash_move_forward_ex(Z_ARRVAL_P(args), &pos)) {
@@ -2170,7 +2170,7 @@ static void soap_call_function_handler(INTERNAL_FUNCTION_PARAMETERS, zend_proper
 		builtin_function->internal_function.handler(INTERNAL_FUNCTION_PARAM_PASSTHRU);
 	} else {
 		int arg_count = ZEND_NUM_ARGS();
-		zval **arguments = (zval **) emalloc(sizeof(zval *) * arg_count);
+		zval **arguments = (zval **) safe_emalloc(sizeof(zval *), arg_count, 0);
 
 		zend_get_parameters_array(ht, arg_count, arguments);
 		do_soap_call(this_ptr, function, Z_STRLEN(function_name->element) + 1, arg_count, arguments, return_value, NULL, NULL, NULL, NULL TSRMLS_CC);
@@ -2275,7 +2275,7 @@ static void deserialize_parameters(xmlNodePtr params, sdlFunctionPtr function, i
 			zend_hash_move_forward(function->requestParameters);
 		}
 		if (use_names) {
-			tmp_parameters = emalloc(num_of_params * sizeof(zval *));
+			tmp_parameters = safe_emalloc(num_of_params, sizeof(zval *), 0);
 			zend_hash_internal_pointer_reset(function->requestParameters);
 			while (zend_hash_get_current_data(function->requestParameters, (void **)&param) == SUCCESS) {
 				val = get_node(params, (*param)->paramName);
@@ -2307,7 +2307,7 @@ static void deserialize_parameters(xmlNodePtr params, sdlFunctionPtr function, i
 			trav = trav->next;
 		}
 		if (num_of_params > 0) {
-			tmp_parameters = emalloc(num_of_params * sizeof(zval *));
+			tmp_parameters = safe_emalloc(num_of_params, sizeof(zval *), 0);
 
 			trav = params;
 			while (trav != 0 && cur_param < num_of_params) {