php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35 ImageCopyResized returns wrong value
Submitted: 1998-02-04 07:28 UTC Modified: 1998-02-06 05:24 UTC
From: ed at dsv dot nl Assigned:
Status: Closed Package: Other
PHP Version: 3.0b4 OS: All
Private report: No CVE-ID: None
 [1998-02-04 07:28 UTC] ed at dsv dot nl
Instead of returning a pointer to the newly created image, ImageCopyResized returns TRUE.

Make these changes in gd.c, recompile, and everything works fine again:

void php3_imagecopyresized(INTERNAL_FUNCTION_PARAMETERS) {
        YYSTYPE *SIM, *DIM, *SX, *SY, *SW, *SH, *DX, *DY, *DW, *DH;

/**** new var *******
        int ind;
********************/ 

        gdImagePtr im_dst;
        gdImagePtr im_src;
        int srcH, srcW, dstH, dstW, srcY, srcX, dstY, dstX;
        int ind_type;
        GD_TLS_VARS;

        if (ARG_COUNT(ht) != 10 ||
                getParameters(ht, 10, &DIM, &SIM, &DX, &DY, &SX, &SY, &DW, &DH,
                                          &SW, &SH) == FAILURE) {
                WRONG_PARAM_COUNT;
        }

        convert_to_long(SIM);
        convert_to_long(DIM);
        convert_to_long(SX);
        convert_to_long(SY);
        convert_to_long(SW);
        convert_to_long(SH);
        convert_to_long(DX);
        convert_to_long(DY);
        convert_to_long(DW);
        convert_to_long(DH);

        srcX = SX->value.lval;
        srcY = SY->value.lval;
        srcH = SH->value.lval;
        srcW = SW->value.lval;
        dstX = DX->value.lval;
        dstY = DY->value.lval;
        dstH = DH->value.lval;
        dstW = DW->value.lval;

        im_src = php3_list_find(SIM->value.lval, &ind_type);

        if(!im_src || ind_type != GD_GLOBAL(le_gd)) {
                php3_error(E_WARNING, "Unable to find source image pointer");
                RETURN_FALSE;
        }

        im_dst = php3_list_find(DIM->value.lval, &ind_type);
        if(!im_dst || ind_type != GD_GLOBAL(le_gd)) {
                php3_error(E_WARNING, "Unable to find destination image pointer"
);
                RETURN_FALSE;
        }

        gdImageCopyResized(im_dst, im_src, dstX, dstY, srcX, srcY, dstW, dstH,
                                           srcW, srcH);
/******* WRONG RETURN VALUE ********
//        RETURN_TRUE;
***********************************/

/******* Add these lines ***********
        ind = php3_list_insert(im_dst, GD_GLOBAL(le_gd));

        RETURN_LONG(ind);
***********************************/
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-02-06 05:24 UTC] ssb
ImageCopyResized() works, it was his script that had
an obscure bug.

 [2020-02-05 10:04 UTC] nikic@php.net
Automatic comment from SVN on behalf of nikic
Revision: http://svn.php.net/viewvc/?view=revision&revision=349126
Log: Fix typo on Runtime Configuration page

Patch by berezuev.

Closes php/doc-en#35.
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Dec 01 23:03:34 2021 UTC