From 6e13303e4dc460477c7531b3cd822dfb564c9dec Mon Sep 17 00:00:00 2001 From: Nicolas Vion Date: Thu, 30 Oct 2008 00:51:55 +0000 Subject: [PATCH] * Add check after emalloc in caca_draw_thin_polyline --- caca-php/php_caca.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/caca-php/php_caca.c b/caca-php/php_caca.c index fb13a81..0a72fe5 100644 --- a/caca-php/php_caca.c +++ b/caca-php/php_caca.c @@ -687,12 +687,15 @@ PHP_FUNCTION(caca_attr_to_rgb12_bg) { } PHP_FUNCTION(caca_attr_to_argb64) { + //TODO: write or delete } PHP_FUNCTION(caca_utf8_to_utf32) { + //TODO: write or delete } PHP_FUNCTION(caca_utf32_to_utf8) { + //TODO: write or delete } PHP_FUNCTION(caca_utf32_to_cp437) { @@ -796,6 +799,10 @@ PHP_FUNCTION(caca_draw_thin_polyline) { int tbl_count = 0; tbl_x = malloc(sizeof(int) * lenmax); tbl_y = malloc(sizeof(int) * lenmax); + + if (!tbl_x || !tbl_y) { + RETURN_FALSE; + } HashPosition pos; zval **pt, **x, **y; @@ -1040,7 +1047,7 @@ PHP_FUNCTION(caca_set_dither_palette) { zval **color, **value; int i, j; for (i = 0; i < 256; i++) { - if (zend_hash_index_find(Z_ARRVAL_P(arr), i, (void**) &color) == FAILURE | Z_TYPE_P(*color) != IS_ARRAY) { + if (zend_hash_index_find(Z_ARRVAL_P(arr), i, (void**) &color) == FAILURE || Z_TYPE_P(*color) != IS_ARRAY) { RETURN_FALSE; } for (j = 0; j < 4; j++) { @@ -1064,7 +1071,7 @@ PHP_FUNCTION(caca_set_dither_palette_gd) { ZEND_FETCH_RESOURCE(dither, caca_dither_t*, &_zval1, -1, PHP_CACA_CANVAS_RES_NAME, le_caca_dither); gdImage *img = fetch_external_resource(_zval2, "gd"); - if (!img | img->trueColor | gdMaxColors != 256) { + if (!img || img->trueColor || gdMaxColors != 256) { RETURN_FALSE; } @@ -1156,6 +1163,7 @@ PHP_FUNCTION(caca_set_dither_antialias) { } PHP_FUNCTION(caca_get_dither_antialias_list) { + //TODO: write } PHP_FUNCTION(caca_get_dither_antialias) { @@ -1361,6 +1369,7 @@ PHP_FUNCTION(caca_get_font_blocks) { } PHP_FUNCTION(caca_render_canvas) { + //TODO: write } PHP_FUNCTION(caca_canvas_set_figfont) { @@ -1546,7 +1555,7 @@ PHP_FUNCTION(caca_export_string) { size_t len; buffer = caca_export_memory(canvas, type, &len); copy = emalloc(len); - if (!buffer | !copy) { + if (!buffer || !copy) { RETURN_FALSE; } memcpy(copy, buffer, len);