Skip to content

Commit

Permalink
Fix #81032: GD install is affected by external libgd installation
Browse files Browse the repository at this point in the history
This PR replaces the bundled libgd includes from #include <foo.h> with
#include "foo.h" for gd-related headers to avoid including headers that
may be available in system directories instead of the expected local
headers.

Closes GH-6975.
  • Loading branch information
flavioheleno authored and cmb69 committed May 14, 2021
1 parent f6c15e2 commit 28e7add
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 12 deletions.
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ PHP NEWS
. Fixed bug #80901 (Info leak in ftp extension). (cmb)
. Fixed bug #79100 (Wrong FTP error messages). (cmb)

- GD:
. Fixed bug #81032 (GD install is affected by external libgd installation).
(Flavio Heleno, cmb)

- MBString:
. Fixed bug #81011 (mb_convert_encoding removes references from arrays). (cmb)

Expand Down
24 changes: 17 additions & 7 deletions ext/gd/gd.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,23 @@

static int le_gd, le_gd_font;

#include <gd.h>
#include <gd_errors.h>
#include <gdfontt.h> /* 1 Tiny font */
#include <gdfonts.h> /* 2 Small font */
#include <gdfontmb.h> /* 3 Medium bold font */
#include <gdfontl.h> /* 4 Large font */
#include <gdfontg.h> /* 5 Giant font */
#ifdef HAVE_GD_BUNDLED
# include "libgd/gd.h"
# include "libgd/gd_errors.h"
# include "libgd/gdfontt.h" /* 1 Tiny font */
# include "libgd/gdfonts.h" /* 2 Small font */
# include "libgd/gdfontmb.h" /* 3 Medium bold font */
# include "libgd/gdfontl.h" /* 4 Large font */
# include "libgd/gdfontg.h" /* 5 Giant font */
#else
# include <gd.h>
# include <gd_errors.h>
# include <gdfontt.h> /* 1 Tiny font */
# include <gdfonts.h> /* 2 Small font */
# include <gdfontmb.h> /* 3 Medium bold font */
# include <gdfontl.h> /* 4 Large font */
# include <gdfontg.h> /* 5 Giant font */
#endif

#if defined(HAVE_GD_FREETYPE) && defined(HAVE_GD_BUNDLED)
# include <ft2build.h>
Expand Down
3 changes: 2 additions & 1 deletion ext/gd/libgd/gd_crop.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
* (end code)
**/

#include <gd.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#include "gd.h"

static int gdGuessBackgroundColorFromCorners(gdImagePtr im, int *color);
static int gdColorMatch(gdImagePtr im, int col1, int col2, float threshold);

Expand Down
2 changes: 1 addition & 1 deletion ext/gd/libgd/gd_interpolation.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
#include <string.h>
#include <math.h>

#include <gd.h>
#include "gd.h"
#include "gdhelpers.h"

#ifdef _MSC_VER
Expand Down
6 changes: 3 additions & 3 deletions ext/gd/libgd/gd_wbmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@
----------------------------------------------------------------------------
*/

#include <gd.h>
#include <gdfonts.h>
#include <gd_errors.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

#include "gd.h"
#include "gdfonts.h"
#include "gd_errors.h"
#include "wbmp.h"


Expand Down

0 comments on commit 28e7add

Please sign in to comment.