[gegl] Issue #152 - Program crash after trying to invert colors in selection
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] Issue #152 - Program crash after trying to invert colors in selection
- Date: Tue, 16 Apr 2019 16:39:31 +0000 (UTC)
commit 4865f13719faee7fd2e4d154105bd1d8c3de927b
Author: Ell <ell_se yahoo com>
Date: Tue Apr 16 12:21:48 2019 -0400
Issue #152 - Program crash after trying to invert colors in selection
In gegl:invert[-gamma], fix the number of processed samples when
using the generic code-path for 8-bpc buffers, fixing a buffer
overflow.
operations/common/invert-common.h | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
---
diff --git a/operations/common/invert-common.h b/operations/common/invert-common.h
index a88ace184..ae754d681 100644
--- a/operations/common/invert-common.h
+++ b/operations/common/invert-common.h
@@ -14,14 +14,15 @@ typedef gboolean (* ProcessFunc) (GeglOperation *op,
INVERT_CAT (process_, INVERT_CAT (model_suffix, INVERT_CAT (_, type_suffix)))
static gboolean
-process_int (ProcessFunc func,
- guint32 mask,
- GeglOperation *op,
+process_int (GeglOperation *op,
void *in_buf,
void *out_buf,
glong samples,
const GeglRectangle *roi,
- gint level)
+ gint level,
+ guint32 mask,
+ gint bpp,
+ ProcessFunc func)
{
const guint8 *in = in_buf;
guint8 *out = out_buf;
@@ -34,6 +35,8 @@ process_int (ProcessFunc func,
return func (op, in_buf, out_buf, samples, roi, level);
}
+ samples *= bpp;
+
while (samples && (guintptr) in % 4)
{
*out++ = *in++ ^ (guint8) mask;
@@ -195,7 +198,7 @@ PROCESS_FUNC (PROCESS_MODEL_SUFFIX, u8) (GeglOperation *op,
const GeglRectangle *roi,
gint level)
{
- return process_int (PROCESS_FUNC (PROCESS_MODEL_SUFFIX, u8_),
+ return process_int (op, in_buf, out_buf, samples, roi, level,
#if ! PROCESS_HAS_ALPHA
0xffffffff,
#elif PROCESS_N_COMPONENTS == 1
@@ -203,9 +206,8 @@ PROCESS_FUNC (PROCESS_MODEL_SUFFIX, u8) (GeglOperation *op,
#elif PROCESS_N_COMPONENTS == 3
0x00ffffff,
#endif
- op, in_buf, out_buf,
- (PROCESS_N_COMPONENTS + PROCESS_HAS_ALPHA) * samples,
- roi, level);
+ PROCESS_N_COMPONENTS + PROCESS_HAS_ALPHA,
+ PROCESS_FUNC (PROCESS_MODEL_SUFFIX, u8_));
}
#define PROCESS_TYPE_SUFFIX u16
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]