[gimp] app, plug-ins: move GIMP_BRUSH_MAX_SIZE to gimpbrush-header.h



commit 8195a5626181e1a899afdf872626c9033021b24a
Author: Michael Natterer <mitch gimp org>
Date:   Fri Jul 6 12:31:06 2018 +0200

    app, plug-ins: move GIMP_BRUSH_MAX_SIZE to gimpbrush-header.h
    
    and use it in the brush file plug-ins.

 app/core/gimpbrush-header.h  | 4 ++++
 app/core/gimpbrush.h         | 1 -
 app/paint/gimpbrushcore.c    | 2 +-
 app/paint/gimppaintoptions.c | 1 +
 app/paint/gimpsmudge.c       | 1 +
 plug-ins/common/file-gbr.c   | 4 ++--
 plug-ins/common/file-gih.c   | 4 ++--
 7 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/app/core/gimpbrush-header.h b/app/core/gimpbrush-header.h
index 5a8ea41838..62f6840085 100644
--- a/app/core/gimpbrush-header.h
+++ b/app/core/gimpbrush-header.h
@@ -18,9 +18,12 @@
 #ifndef __GIMP_BRUSH_HEADER_H__
 #define __GIMP_BRUSH_HEADER_H__
 
+
 #define GIMP_BRUSH_FILE_VERSION  2
 #define GIMP_BRUSH_MAGIC         (('G' << 24) + ('I' << 16) + \
                                   ('M' << 8)  + ('P' << 0))
+#define GIMP_BRUSH_MAX_SIZE      10000 /* Max size in either dimension in px */
+
 
 /*  All field entries are MSB  */
 
@@ -41,4 +44,5 @@ struct _GimpBrushHeader
  *  comes the brush data--width * height * bytes bytes of it...
  */
 
+
 #endif  /*  __GIMP_BRUSH_HEADER_H__  */
diff --git a/app/core/gimpbrush.h b/app/core/gimpbrush.h
index 1e7c1e8776..c82c10e921 100644
--- a/app/core/gimpbrush.h
+++ b/app/core/gimpbrush.h
@@ -21,7 +21,6 @@
 
 #include "gimpdata.h"
 
-#define GIMP_BRUSH_MAX_SIZE 10000 /* Max size in either dimension in px */
 
 #define GIMP_TYPE_BRUSH            (gimp_brush_get_type ())
 #define GIMP_BRUSH(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_BRUSH, GimpBrush))
diff --git a/app/paint/gimpbrushcore.c b/app/paint/gimpbrushcore.c
index f16f0f8d45..15dfa19434 100644
--- a/app/paint/gimpbrushcore.c
+++ b/app/paint/gimpbrushcore.c
@@ -30,7 +30,7 @@
 
 #include "gegl/gimp-babl.h"
 
-#include "core/gimpbrush.h"
+#include "core/gimpbrush-header.h"
 #include "core/gimpbrushgenerated.h"
 #include "core/gimpdrawable.h"
 #include "core/gimpdynamics.h"
diff --git a/app/paint/gimppaintoptions.c b/app/paint/gimppaintoptions.c
index b56b13b47e..7653af022f 100644
--- a/app/paint/gimppaintoptions.c
+++ b/app/paint/gimppaintoptions.c
@@ -27,6 +27,7 @@
 #include "paint-types.h"
 
 #include "core/gimp.h"
+#include "core/gimpbrush-header.h"
 #include "core/gimpbrushgenerated.h"
 #include "core/gimpimage.h"
 #include "core/gimpdynamics.h"
diff --git a/app/paint/gimpsmudge.c b/app/paint/gimpsmudge.c
index b8e108e4b3..1b3d125cd1 100644
--- a/app/paint/gimpsmudge.c
+++ b/app/paint/gimpsmudge.c
@@ -29,6 +29,7 @@
 
 #include "core/gimp-palettes.h"
 #include "core/gimpbrush.h"
+#include "core/gimpbrush-header.h"
 #include "core/gimpdrawable.h"
 #include "core/gimpdynamics.h"
 #include "core/gimpimage.h"
diff --git a/plug-ins/common/file-gbr.c b/plug-ins/common/file-gbr.c
index 9f5058702d..38af555ff0 100644
--- a/plug-ins/common/file-gbr.c
+++ b/plug-ins/common/file-gbr.c
@@ -386,8 +386,8 @@ load_image (GFile   *file,
   bh.bytes        = g_ntohl (bh.bytes);
 
   /* Sanitize values */
-  if ((bh.width  == 0) || (bh.width  > GIMP_MAX_IMAGE_SIZE) ||
-      (bh.height == 0) || (bh.height > GIMP_MAX_IMAGE_SIZE) ||
+  if ((bh.width  == 0) || (bh.width  > GIMP_BRUSH_MAX_SIZE) ||
+      (bh.height == 0) || (bh.height > GIMP_BRUSH_MAX_SIZE) ||
       ((bh.bytes != 1) && (bh.bytes != 2) && (bh.bytes != 4) &&
        (bh.bytes != 18)) ||
       (G_MAXSIZE / bh.width / bh.height / MAX (4, bh.bytes) < 1))
diff --git a/plug-ins/common/file-gih.c b/plug-ins/common/file-gih.c
index 4f30ef18ab..0d93212d30 100644
--- a/plug-ins/common/file-gih.c
+++ b/plug-ins/common/file-gih.c
@@ -479,8 +479,8 @@ gih_load_one_brush (GInputStream  *input,
   bh.spacing      = g_ntohl (bh.spacing);
 
   /* Sanitize values */
-  if ((bh.width  == 0) || (bh.width  > GIMP_MAX_IMAGE_SIZE) ||
-      (bh.height == 0) || (bh.height > GIMP_MAX_IMAGE_SIZE) ||
+  if ((bh.width  == 0) || (bh.width  > GIMP_BRUSH_MAX_SIZE) ||
+      (bh.height == 0) || (bh.height > GIMP_BRUSH_MAX_SIZE) ||
       ((bh.bytes != 1) && (bh.bytes != 4)) ||
       (G_MAXSIZE / bh.width / bh.height / bh.bytes < 1))
     {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]