Skip to content
Browse files

fixed #3 Sundown\Render\HTML::list_box specifies unexpected variable …

…type.

`zend_parse_parameters` must match zval and C-types. Sundown\Render\HTML::list_box and list_item specifies
int as 3rd parameter but actually it must specify long type.
  • Loading branch information...
1 parent baf15f4 commit 8016e3fc40b85ef0eb735ae703210007aea7679f @chobie committed Jan 6, 2012
Showing with 14 additions and 15 deletions.
  1. +6 −6 src/render_base.c
  2. +8 −9 src/render_html.c
View
12 src/render_base.c
@@ -294,13 +294,13 @@ PHP_METHOD(sundown_render_base, hrule)
*/
PHP_METHOD(sundown_render_base, list_box)
{
- char *contents, *list_type;
- int contents_len, list_type_len;
+ char *contents;
+ int contents_len, list_type;
zval *buffer;
php_sundown_buffer_t *object;
if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
- "zss", &buffer, &contents, &contents_len, &list_type, &list_type_len) == FAILURE){
+ "zsl", &buffer, &contents, &contents_len, &list_type) == FAILURE){
return;
}
@@ -313,13 +313,13 @@ PHP_METHOD(sundown_render_base, list_box)
*/
PHP_METHOD(sundown_render_base, list_item)
{
- char *text, *list_type;
- int text_len, list_type_len;
+ char *text;
+ int text_len, list_type;
zval *buffer;
php_sundown_buffer_t *object;
if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
- "zss", &buffer,&text, &text_len, &list_type, &list_type_len) == FAILURE){
+ "zsl", &buffer,&text, &text_len, &list_type) == FAILURE){
return;
}
View
17 src/render_html.c
@@ -338,12 +338,11 @@ PHP_METHOD(sundown_render_html, hrule)
PHP_METHOD(sundown_render_html, list_box)
{
char *contents;
- int contents_len, list_type;
+ long contents_len, list_type;
zval *buffer;
struct buf *input;
php_sundown_buffer_t *object;
php_sundown_render_html_t *html;
-
if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,
"zsl", &buffer, &contents, &contents_len, &list_type) == FAILURE){
return;
@@ -352,9 +351,10 @@ PHP_METHOD(sundown_render_html, list_box)
html = (php_sundown_render_html_t *) zend_object_store_get_object(getThis() TSRMLS_CC);
object = (php_sundown_buffer_t *) zend_object_store_get_object(buffer TSRMLS_CC);
php_sundown_render_base_t *base = (php_sundown_render_base_t *) zend_object_store_get_object(getThis() TSRMLS_CC);\
- input = str2buf(contents, strlen(contents));
+ input = str2buf(contents, contents_len);
html->cb.list(object->buffer,input,list_type, &base->html);
- bufrelease(input);
+ if (input != NULL)
+ bufrelease(input);
}
/* }}} */
@@ -363,7 +363,7 @@ PHP_METHOD(sundown_render_html, list_box)
PHP_METHOD(sundown_render_html, list_item)
{
char *text;
- int text_len, list_type;
+ long text_len, list_type;
zval *buffer;
struct buf *input;
php_sundown_buffer_t *object;
@@ -377,11 +377,10 @@ PHP_METHOD(sundown_render_html, list_item)
html = (php_sundown_render_html_t *) zend_object_store_get_object(getThis() TSRMLS_CC);
object = (php_sundown_buffer_t *) zend_object_store_get_object(buffer TSRMLS_CC);
php_sundown_render_base_t *base = (php_sundown_render_base_t *) zend_object_store_get_object(getThis() TSRMLS_CC);
- //why text_len does not work properly?
- input = str2buf(text, strlen(text));
- // Todo
+ input = str2buf(text, text_len);
html->cb.listitem(object->buffer,input,list_type, &base->html);
- bufrelease(input);
+ if (input != NULL)
+ bufrelease(input);
}
/* }}} */

0 comments on commit 8016e3f

Please sign in to comment.
Something went wrong with that request. Please try again.