Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leaks in Phalcon\Image\* #1249

Merged
merged 4 commits into from Sep 18, 2013
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Bug fixes in Phalcon\Image\Adapter
  • Loading branch information
sjinks committed Sep 18, 2013
commit c3977267bef2b2eb0c3641bc13295678db426def
25 changes: 12 additions & 13 deletions ext/image/adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -715,29 +715,29 @@ PHP_METHOD(Phalcon_Image_Adapter, text){
phalcon_fetch_params(1, 1, 6, &text, &offset_x, &offset_y, &opacity, &color, &size, &fontfile);

if (!offset_x) {
PHALCON_INIT_NVAR(offset_x);
PHALCON_INIT_VAR(offset_x);
} else {
PHALCON_SEPARATE_PARAM(offset_x);
}

if (!offset_y) {
PHALCON_INIT_NVAR(offset_y);
PHALCON_INIT_VAR(offset_y);
} else {
PHALCON_SEPARATE_PARAM(offset_y);
}

if (Z_TYPE_P(offset_x) == IS_NULL ) {
if (Z_TYPE_P(offset_x) == IS_NULL) {
PHALCON_INIT_NVAR(offset_x);
ZVAL_BOOL(offset_x, 0);
ZVAL_FALSE(offset_x);
}

if (Z_TYPE_P(offset_y) == IS_NULL) {
PHALCON_INIT_NVAR(offset_y);
ZVAL_BOOL(offset_y, 0);
ZVAL_FALSE(offset_y);
}

if (!opacity) {
PHALCON_INIT_NVAR(opacity);
PHALCON_INIT_VAR(opacity);
ZVAL_LONG(opacity, 100);
} else if (Z_TYPE_P(opacity) == IS_NULL) {
PHALCON_SEPARATE_PARAM(opacity);
Expand Down Expand Up @@ -767,7 +767,7 @@ PHP_METHOD(Phalcon_Image_Adapter, text){
}

if (!size) {
PHALCON_INIT_NVAR(size);
PHALCON_INIT_VAR(size);
ZVAL_LONG(size, 12);
} else if (Z_TYPE_P(size) == IS_NULL) {
PHALCON_SEPARATE_PARAM(size);
Expand All @@ -776,7 +776,7 @@ PHP_METHOD(Phalcon_Image_Adapter, text){
}

if (!fontfile) {
PHALCON_INIT_NVAR(fontfile);
PHALCON_INIT_VAR(fontfile);
}

c = Z_STRVAL_P(color);
Expand All @@ -785,23 +785,23 @@ PHP_METHOD(Phalcon_Image_Adapter, text){
PHALCON_INIT_NVAR(tmp_color);
phalcon_substr(tmp_color, color, 1, 0);
} else {
PHALCON_CPY_WRT(tmp_color, color);
PHALCON_CPY_WRT_CTOR(tmp_color, color);
}

if (Z_STRLEN_P(tmp_color) == 3) {
/* Convert RGB to RRGGBB */
c = Z_STRVAL_P(tmp_color);
assert(!IS_INTERNED(c));
STR_REALLOC(c, 7);
c[6] = '\0';
c[5] = c[2];
c[4] = c[2];
c[3] = c[1];
c[2] = c[1];
c[1] = c[0];
ZVAL_STRING(tmp_color, c, 0);
}

ZVAL_STRING(tmp_color, c, 1);

if (Z_STRLEN_P(tmp_color) < 6) {
PHALCON_THROW_EXCEPTION_STR(phalcon_image_exception_ce, "color is not valid");
return;
Expand Down Expand Up @@ -898,10 +898,9 @@ PHP_METHOD(Phalcon_Image_Adapter, background){
c[3] = c[1];
c[2] = c[1];
c[1] = c[0];
ZVAL_STRING(tmp_color, c, 0);
}

ZVAL_STRING(tmp_color, c, 0);

if (Z_STRLEN_P(tmp_color) < 6) {
PHALCON_THROW_EXCEPTION_STR(phalcon_image_exception_ce, "Color is not valid");
return;
Expand Down