From d7a59c81b9ba69127d72884cf3b85658f14dd059 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E3=82=88=E3=82=84?= Date: Wed, 22 Feb 2012 04:07:51 +0900 Subject: [PATCH] check param_is_null if 1st argument is character id. --- src/php_swfed.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/php_swfed.c b/src/php_swfed.c index bf213d5..1adb6f5 100644 --- a/src/php_swfed.c +++ b/src/php_swfed.c @@ -60,6 +60,17 @@ } \ } while (0); +static int +param_is_null(int n TSRMLS_DC) { + zval *p; + zend_parse_parameters(n TSRMLS_CC, "z", &p); + if(Z_TYPE_P(p) == IS_NULL) { + return 1; // true + } + return 0; // false +} + + /* If you declare any globals in php_swfed.h uncomment this: ZEND_DECLARE_MODULE_GLOBALS(swfed) */ @@ -1110,6 +1121,10 @@ PHP_METHOD(swfed, replaceBitmapData) { swf_object_t *swf = NULL; int result = 0; int bitmap_format; + if (param_is_null(1 TSRMLS_CC)) { + php_error(E_WARNING, "%s() 1st arg must be not NULL", get_active_function_name(TSRMLS_C)); + RETURN_FALSE; /* XXX */ + } switch (ZEND_NUM_ARGS()) { default: WRONG_PARAM_COUNT; @@ -1229,6 +1244,10 @@ PHP_METHOD(swfed, applyShapeMatrixFactor) { long trans_x = 0, trans_y = 0; swf_object_t *swf = NULL; int result; + if (param_is_null(1 TSRMLS_CC)) { + php_error(E_WARNING, "%s() 1st arg must be not NULL", get_active_function_name(TSRMLS_C)); + RETURN_FALSE; /* XXX */ + } if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ldddll", &shape_id, &scale_x, &scale_y, &rotate_rad, &trans_x, &trans_y) == FAILURE) { @@ -1251,6 +1270,10 @@ PHP_METHOD(swfed, applyShapeRectFactor) { long trans_x = 0, trans_y = 0; swf_object_t *swf = NULL; int result; + if (param_is_null(1 TSRMLS_CC)) { + php_error(E_WARNING, "%s() 1st arg must be not NULL", get_active_function_name(TSRMLS_C)); + RETURN_FALSE; /* XXX */ + } if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lddll", &shape_id, &scale_x, &scale_y, &trans_x, &trans_y) == FAILURE) { @@ -1282,6 +1305,10 @@ PHP_METHOD(swfed, getSoundData) { unsigned char *data = NULL; char *new_buff = NULL; swf_object_t *swf = NULL; + if (param_is_null(1 TSRMLS_CC)) { + php_error(E_WARNING, "%s() 1st arg must be not NULL", get_active_function_name(TSRMLS_C)); + RETURN_FALSE; /* XXX */ + } if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &sound_id) == FAILURE) { RETURN_FALSE; @@ -1308,6 +1335,10 @@ PHP_METHOD(swfed, replaceMLDData) { int sound_id = 0; swf_object_t *swf = NULL; int result = 0; + if (param_is_null(1 TSRMLS_CC)) { + php_error(E_WARNING, "%s() 1st arg must be not NULL", get_active_function_name(TSRMLS_C)); + RETURN_FALSE; + } switch (ZEND_NUM_ARGS()) { default: WRONG_PARAM_COUNT; @@ -1335,6 +1366,10 @@ PHP_METHOD(swfed, getEditString) { char *data = NULL, *new_buff = NULL; int str_len = 0; int error = 0; + if (param_is_null(1 TSRMLS_CC)) { + php_error(E_WARNING, "%s() 1st arg must be not NULL", get_active_function_name(TSRMLS_C)); + RETURN_FALSE; + } if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &var_name, &var_name_len) == FAILURE) { RETURN_FALSE; @@ -1365,6 +1400,10 @@ PHP_METHOD(swfed, replaceEditString) { int var_name_len = 0, ini_text_len = 0; swf_object_t *swf = NULL; int result = 0; + if (param_is_null(1 TSRMLS_CC)) { + php_error(E_WARNING, "%s() 1st arg must be not NULL", get_active_function_name(TSRMLS_C)); + RETURN_FALSE; + } if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", &var_name, &var_name_len, &ini_text, &ini_text_len) == FAILURE) { @@ -1527,6 +1566,10 @@ PHP_METHOD(swfed, replaceMovieClip) { swf_object_t *swf = NULL; int unused_cid_purge = 1; // ¥Ç¥Õ¥©¥ë¥È on int result = 0; + if (param_is_null(1 TSRMLS_CC)) { + php_error(E_WARNING, "%s() 1st arg must be not NULL", get_active_function_name(TSRMLS_C)); + RETURN_FALSE; + } switch (ZEND_NUM_ARGS()) { default: WRONG_PARAM_COUNT; -- 2.11.0