Commit 89ec6691 authored by Manish Singh's avatar Manish Singh

fixed memory overrun error

* app/convert.c: fixed memory overrun error

* app/gdisplay.c
* app/menus.c: reapplied the tools patch from Nether, looks
like it doesn't trip up anymore. Added some sanity checks
anyway

* app/disp_callbacks.c
* app/transform_core.c: plugged some harmless build warnings

-Yosh
parent 1b62534d
Wed Mar 11 00:27:35 PST 1998 Manish Singh <yosh@gimp.org>
* app/convert.c: fixed memory overrun error
* app/gdisplay.c
* app/menus.c: reapplied the tools patch from Nether, looks
like it doesn't trip up anymore. Added some sanity checks
anyway
* app/disp_callbacks.c
* app/transform_core.c: plugged some harmless build warnings
1998-03-11 Larry Ewing <lewing@discord.isc.tamu.edu>
* app/undo.c
......
......@@ -1066,7 +1066,7 @@ generate_histogram_rgb (Histogram histogram,
num_found_cols++;
if (num_found_cols > col_limit)
if (num_found_cols >= col_limit)
{
/* There are more colours in the image
* than were allowed. We switch to plain
......
......@@ -1066,7 +1066,7 @@ generate_histogram_rgb (Histogram histogram,
num_found_cols++;
if (num_found_cols > col_limit)
if (num_found_cols >= col_limit)
{
/* There are more colours in the image
* than were allowed. We switch to plain
......
......@@ -41,7 +41,6 @@
#include "scroll.h"
#include "tools.h"
#include "undo.h"
#include "tools.h"
#include "layer_pvt.h" /* ick. */
......@@ -1110,6 +1109,10 @@ gdisplay_active ()
event = gtk_get_current_event ();
event_widget = gtk_get_event_widget (event);
gdk_event_free (event);
if (event_widget == NULL)
return NULL;
toplevel_widget = gtk_widget_get_toplevel (event_widget);
gdisp = g_hash_table_lookup (display_ht, toplevel_widget);
......@@ -1118,7 +1121,6 @@ gdisplay_active ()
if (popup_shell)
{
active_tool_control (DESTROY, gdisp);
gdisp = gtk_object_get_user_data (GTK_OBJECT (popup_shell));
return gdisp;
}
......
......@@ -62,14 +62,6 @@ redraw (GDisplay *gdisp,
}
}
static gint
expose_predicate (GdkEvent *event,
gpointer data)
{
return ((event->type == GDK_EXPOSE) &&
(event->any.window == data));
}
gint
gdisplay_canvas_events (GtkWidget *canvas,
GdkEvent *event)
......@@ -259,12 +251,7 @@ gdisplay_canvas_events (GtkWidget *canvas,
}
else if (mevent->state & GDK_BUTTON2_MASK)
{
/* int flush; */
grab_and_scroll (gdisp, mevent);
/* if (flush)
gdisplays_flush (); */
}
break;
......
......@@ -62,14 +62,6 @@ redraw (GDisplay *gdisp,
}
}
static gint
expose_predicate (GdkEvent *event,
gpointer data)
{
return ((event->type == GDK_EXPOSE) &&
(event->any.window == data));
}
gint
gdisplay_canvas_events (GtkWidget *canvas,
GdkEvent *event)
......@@ -259,12 +251,7 @@ gdisplay_canvas_events (GtkWidget *canvas,
}
else if (mevent->state & GDK_BUTTON2_MASK)
{
/* int flush; */
grab_and_scroll (gdisp, mevent);
/* if (flush)
gdisplays_flush (); */
}
break;
......
......@@ -41,7 +41,6 @@
#include "scroll.h"
#include "tools.h"
#include "undo.h"
#include "tools.h"
#include "layer_pvt.h" /* ick. */
......@@ -1110,6 +1109,10 @@ gdisplay_active ()
event = gtk_get_current_event ();
event_widget = gtk_get_event_widget (event);
gdk_event_free (event);
if (event_widget == NULL)
return NULL;
toplevel_widget = gtk_widget_get_toplevel (event_widget);
gdisp = g_hash_table_lookup (display_ht, toplevel_widget);
......@@ -1118,7 +1121,6 @@ gdisplay_active ()
if (popup_shell)
{
active_tool_control (DESTROY, gdisp);
gdisp = gtk_object_get_user_data (GTK_OBJECT (popup_shell));
return gdisp;
}
......
......@@ -62,14 +62,6 @@ redraw (GDisplay *gdisp,
}
}
static gint
expose_predicate (GdkEvent *event,
gpointer data)
{
return ((event->type == GDK_EXPOSE) &&
(event->any.window == data));
}
gint
gdisplay_canvas_events (GtkWidget *canvas,
GdkEvent *event)
......@@ -259,12 +251,7 @@ gdisplay_canvas_events (GtkWidget *canvas,
}
else if (mevent->state & GDK_BUTTON2_MASK)
{
/* int flush; */
grab_and_scroll (gdisp, mevent);
/* if (flush)
gdisplays_flush (); */
}
break;
......
......@@ -41,7 +41,6 @@
#include "scroll.h"
#include "tools.h"
#include "undo.h"
#include "tools.h"
#include "layer_pvt.h" /* ick. */
......@@ -1110,6 +1109,10 @@ gdisplay_active ()
event = gtk_get_current_event ();
event_widget = gtk_get_event_widget (event);
gdk_event_free (event);
if (event_widget == NULL)
return NULL;
toplevel_widget = gtk_widget_get_toplevel (event_widget);
gdisp = g_hash_table_lookup (display_ht, toplevel_widget);
......@@ -1118,7 +1121,6 @@ gdisplay_active ()
if (popup_shell)
{
active_tool_control (DESTROY, gdisp);
gdisp = gtk_object_get_user_data (GTK_OBJECT (popup_shell));
return gdisp;
}
......
......@@ -1066,7 +1066,7 @@ generate_histogram_rgb (Histogram histogram,
num_found_cols++;
if (num_found_cols > col_limit)
if (num_found_cols >= col_limit)
{
/* There are more colours in the image
* than were allowed. We switch to plain
......
......@@ -29,7 +29,7 @@
#include "procedural_db.h"
#include "scale.h"
#include "tools.h"
#include "gdisplay.h"
static void menus_init (void);
static void menus_foreach (gpointer key,
......@@ -43,7 +43,8 @@ static gint menus_install_accel (GtkWidget *widget,
static void menus_remove_accel (GtkWidget *widget,
gchar *signal_name,
gchar *path);
static void menus_activate_callback (GtkWidget *widget,
GtkMenuEntry *entry);
static GtkMenuEntry menu_items[] =
{
......@@ -298,6 +299,9 @@ menus_create (GtkMenuEntry *entries,
gtk_signal_connect (GTK_OBJECT (entries[i].widget), "remove_accelerator",
(GtkSignalFunc) menus_remove_accel,
entries[i].path);
gtk_signal_connect (GTK_OBJECT (entries[i].widget), "activate",
(GtkSignalFunc) menus_activate_callback,
&entries[i]);
}
}
......@@ -486,3 +490,73 @@ menus_remove_accel (GtkWidget *widget,
g_hash_table_insert (entry_ht, path, g_strdup (""));
}
}
static void
menus_activate_callback (GtkWidget *widget,
GtkMenuEntry *entry)
{
/* These are the functions upon which we won't destroy the
tool... "safe", so to say. All the others are expected to alter
the image, so the tool must be destroyed */
const GtkMenuCallback ignore[]={
image_posterize_cmd_callback,
image_threshold_cmd_callback,
image_color_balance_cmd_callback,
image_brightness_contrast_cmd_callback,
image_hue_saturation_cmd_callback,
image_curves_cmd_callback,
image_levels_cmd_callback,
image_histogram_cmd_callback,
tools_select_cmd_callback,
about_dialog_cmd_callback,
tips_dialog_cmd_callback,
file_new_cmd_callback,
file_open_cmd_callback,
file_save_cmd_callback,
file_save_as_cmd_callback,
file_pref_cmd_callback,
file_close_cmd_callback,
file_quit_cmd_callback,
view_zoomin_cmd_callback,
view_zoomout_cmd_callback,
view_zoom_16_1_callback,
view_zoom_8_1_callback,
view_zoom_4_1_callback,
view_zoom_2_1_callback,
view_zoom_1_1_callback,
view_zoom_1_2_callback,
view_zoom_1_4_callback,
view_zoom_1_8_callback,
view_zoom_1_16_callback,
view_window_info_cmd_callback,
view_toggle_rulers_cmd_callback,
view_toggle_guides_cmd_callback,
view_snap_to_guides_cmd_callback,
channel_ops_duplicate_cmd_callback,
dialogs_lc_cmd_callback,
dialogs_brushes_cmd_callback,
dialogs_patterns_cmd_callback,
dialogs_palette_cmd_callback,
dialogs_gradient_editor_cmd_callback,
dialogs_lc_cmd_callback,
dialogs_indexed_palette_cmd_callback,
dialogs_tools_options_cmd_callback,
file_load_by_extension_callback,
file_save_by_extension_callback
};
int i;
if (active_tool){
for (i=0; i<sizeof(ignore)/sizeof(*ignore); i++)
if (entry->callback == ignore[i])
return;
if (active_tool->gdisp_ptr == NULL)
active_tool_control (DESTROY, active_tool->gdisp_ptr);
else {
GDisplay *gdisp;
gdisp = gdisplay_active ();
if (gdisp == NULL || ((GDisplay*)active_tool->gdisp_ptr)->gimage == gdisp->gimage)
active_tool_control (DESTROY, active_tool->gdisp_ptr);
}
}
}
......@@ -29,7 +29,7 @@
#include "procedural_db.h"
#include "scale.h"
#include "tools.h"
#include "gdisplay.h"
static void menus_init (void);
static void menus_foreach (gpointer key,
......@@ -43,7 +43,8 @@ static gint menus_install_accel (GtkWidget *widget,
static void menus_remove_accel (GtkWidget *widget,
gchar *signal_name,
gchar *path);
static void menus_activate_callback (GtkWidget *widget,
GtkMenuEntry *entry);
static GtkMenuEntry menu_items[] =
{
......@@ -298,6 +299,9 @@ menus_create (GtkMenuEntry *entries,
gtk_signal_connect (GTK_OBJECT (entries[i].widget), "remove_accelerator",
(GtkSignalFunc) menus_remove_accel,
entries[i].path);
gtk_signal_connect (GTK_OBJECT (entries[i].widget), "activate",
(GtkSignalFunc) menus_activate_callback,
&entries[i]);
}
}
......@@ -486,3 +490,73 @@ menus_remove_accel (GtkWidget *widget,
g_hash_table_insert (entry_ht, path, g_strdup (""));
}
}
static void
menus_activate_callback (GtkWidget *widget,
GtkMenuEntry *entry)
{
/* These are the functions upon which we won't destroy the
tool... "safe", so to say. All the others are expected to alter
the image, so the tool must be destroyed */
const GtkMenuCallback ignore[]={
image_posterize_cmd_callback,
image_threshold_cmd_callback,
image_color_balance_cmd_callback,
image_brightness_contrast_cmd_callback,
image_hue_saturation_cmd_callback,
image_curves_cmd_callback,
image_levels_cmd_callback,
image_histogram_cmd_callback,
tools_select_cmd_callback,
about_dialog_cmd_callback,
tips_dialog_cmd_callback,
file_new_cmd_callback,
file_open_cmd_callback,
file_save_cmd_callback,
file_save_as_cmd_callback,
file_pref_cmd_callback,
file_close_cmd_callback,
file_quit_cmd_callback,
view_zoomin_cmd_callback,
view_zoomout_cmd_callback,
view_zoom_16_1_callback,
view_zoom_8_1_callback,
view_zoom_4_1_callback,
view_zoom_2_1_callback,
view_zoom_1_1_callback,
view_zoom_1_2_callback,
view_zoom_1_4_callback,
view_zoom_1_8_callback,
view_zoom_1_16_callback,
view_window_info_cmd_callback,
view_toggle_rulers_cmd_callback,
view_toggle_guides_cmd_callback,
view_snap_to_guides_cmd_callback,
channel_ops_duplicate_cmd_callback,
dialogs_lc_cmd_callback,
dialogs_brushes_cmd_callback,
dialogs_patterns_cmd_callback,
dialogs_palette_cmd_callback,
dialogs_gradient_editor_cmd_callback,
dialogs_lc_cmd_callback,
dialogs_indexed_palette_cmd_callback,
dialogs_tools_options_cmd_callback,
file_load_by_extension_callback,
file_save_by_extension_callback
};
int i;
if (active_tool){
for (i=0; i<sizeof(ignore)/sizeof(*ignore); i++)
if (entry->callback == ignore[i])
return;
if (active_tool->gdisp_ptr == NULL)
active_tool_control (DESTROY, active_tool->gdisp_ptr);
else {
GDisplay *gdisp;
gdisp = gdisplay_active ();
if (gdisp == NULL || ((GDisplay*)active_tool->gdisp_ptr)->gimage == gdisp->gimage)
active_tool_control (DESTROY, active_tool->gdisp_ptr);
}
}
}
......@@ -29,7 +29,7 @@
#include "procedural_db.h"
#include "scale.h"
#include "tools.h"
#include "gdisplay.h"
static void menus_init (void);
static void menus_foreach (gpointer key,
......@@ -43,7 +43,8 @@ static gint menus_install_accel (GtkWidget *widget,
static void menus_remove_accel (GtkWidget *widget,
gchar *signal_name,
gchar *path);
static void menus_activate_callback (GtkWidget *widget,
GtkMenuEntry *entry);
static GtkMenuEntry menu_items[] =
{
......@@ -298,6 +299,9 @@ menus_create (GtkMenuEntry *entries,
gtk_signal_connect (GTK_OBJECT (entries[i].widget), "remove_accelerator",
(GtkSignalFunc) menus_remove_accel,
entries[i].path);
gtk_signal_connect (GTK_OBJECT (entries[i].widget), "activate",
(GtkSignalFunc) menus_activate_callback,
&entries[i]);
}
}
......@@ -486,3 +490,73 @@ menus_remove_accel (GtkWidget *widget,
g_hash_table_insert (entry_ht, path, g_strdup (""));
}
}
static void
menus_activate_callback (GtkWidget *widget,
GtkMenuEntry *entry)
{
/* These are the functions upon which we won't destroy the
tool... "safe", so to say. All the others are expected to alter
the image, so the tool must be destroyed */
const GtkMenuCallback ignore[]={
image_posterize_cmd_callback,
image_threshold_cmd_callback,
image_color_balance_cmd_callback,
image_brightness_contrast_cmd_callback,
image_hue_saturation_cmd_callback,
image_curves_cmd_callback,
image_levels_cmd_callback,
image_histogram_cmd_callback,
tools_select_cmd_callback,
about_dialog_cmd_callback,
tips_dialog_cmd_callback,
file_new_cmd_callback,
file_open_cmd_callback,
file_save_cmd_callback,
file_save_as_cmd_callback,
file_pref_cmd_callback,
file_close_cmd_callback,
file_quit_cmd_callback,
view_zoomin_cmd_callback,
view_zoomout_cmd_callback,
view_zoom_16_1_callback,
view_zoom_8_1_callback,
view_zoom_4_1_callback,
view_zoom_2_1_callback,
view_zoom_1_1_callback,
view_zoom_1_2_callback,
view_zoom_1_4_callback,
view_zoom_1_8_callback,
view_zoom_1_16_callback,
view_window_info_cmd_callback,
view_toggle_rulers_cmd_callback,
view_toggle_guides_cmd_callback,
view_snap_to_guides_cmd_callback,
channel_ops_duplicate_cmd_callback,
dialogs_lc_cmd_callback,
dialogs_brushes_cmd_callback,
dialogs_patterns_cmd_callback,
dialogs_palette_cmd_callback,
dialogs_gradient_editor_cmd_callback,
dialogs_lc_cmd_callback,
dialogs_indexed_palette_cmd_callback,
dialogs_tools_options_cmd_callback,
file_load_by_extension_callback,
file_save_by_extension_callback
};
int i;
if (active_tool){
for (i=0; i<sizeof(ignore)/sizeof(*ignore); i++)
if (entry->callback == ignore[i])
return;
if (active_tool->gdisp_ptr == NULL)
active_tool_control (DESTROY, active_tool->gdisp_ptr);
else {
GDisplay *gdisp;
gdisp = gdisplay_active ();
if (gdisp == NULL || ((GDisplay*)active_tool->gdisp_ptr)->gimage == gdisp->gimage)
active_tool_control (DESTROY, active_tool->gdisp_ptr);
}
}
}
......@@ -838,8 +838,8 @@ transform_core_do (gimage, drawable, float_tiles, interpolation, matrix)
double dx1, dy1, dx2, dy2, dx3, dy3, dx4, dy4;
double xinc, yinc, winc;
double tx, ty, tw;
double ttx, tty;
double dx, dy;
double ttx = 0.0, tty = 0.0;
double dx = 0.0, dy = 0.0;
unsigned char * dest, * d;
unsigned char * src[16];
double src_a[16][MAX_CHANNELS];
......@@ -1183,7 +1183,6 @@ transform_core_paste (gimage, drawable, tiles, new_layer)
{
Layer * layer;
Layer * floating_layer;
int layer_type;
if (new_layer)
{
......
......@@ -838,8 +838,8 @@ transform_core_do (gimage, drawable, float_tiles, interpolation, matrix)
double dx1, dy1, dx2, dy2, dx3, dy3, dx4, dy4;
double xinc, yinc, winc;
double tx, ty, tw;
double ttx, tty;
double dx, dy;
double ttx = 0.0, tty = 0.0;
double dx = 0.0, dy = 0.0;
unsigned char * dest, * d;
unsigned char * src[16];
double src_a[16][MAX_CHANNELS];
......@@ -1183,7 +1183,6 @@ transform_core_paste (gimage, drawable, tiles, new_layer)
{
Layer * layer;
Layer * floating_layer;
int layer_type;
if (new_layer)
{
......
......@@ -29,7 +29,7 @@
#include "procedural_db.h"
#include "scale.h"
#include "tools.h"
#include "gdisplay.h"
static void menus_init (void);
static void menus_foreach (gpointer key,
......@@ -43,7 +43,8 @@ static gint menus_install_accel (GtkWidget *widget,
static void menus_remove_accel (GtkWidget *widget,
gchar *signal_name,
gchar *path);
static void menus_activate_callback (GtkWidget *widget,
GtkMenuEntry *entry);
static GtkMenuEntry menu_items[] =
{
......@@ -298,6 +299,9 @@ menus_create (GtkMenuEntry *entries,
gtk_signal_connect (GTK_OBJECT (entries[i].widget), "remove_accelerator",
(GtkSignalFunc) menus_remove_accel,
entries[i].path);
gtk_signal_connect (GTK_OBJECT (entries[i].widget), "activate",
(GtkSignalFunc) menus_activate_callback,
&entries[i]);
}
}
......@@ -486,3 +490,73 @@ menus_remove_accel (GtkWidget *widget,
g_hash_table_insert (entry_ht, path, g_strdup (""));
}
}
static void
menus_activate_callback (GtkWidget *widget,
GtkMenuEntry *entry)
{
/* These are the functions upon which we won't destroy the
tool... "safe", so to say. All the others are expected to alter
the image, so the tool must be destroyed */
const GtkMenuCallback ignore[]={
image_posterize_cmd_callback,
image_threshold_cmd_callback,
image_color_balance_cmd_callback,
image_brightness_contrast_cmd_callback,
image_hue_saturation_cmd_callback,
image_curves_cmd_callback,
image_levels_cmd_callback,
image_histogram_cmd_callback,
tools_select_cmd_callback,
about_dialog_cmd_callback,
tips_dialog_cmd_callback,
file_new_cmd_callback,
file_open_cmd_callback,
file_save_cmd_callback,
file_save_as_cmd_callback,
file_pref_cmd_callback,
file_close_cmd_callback,
file_quit_cmd_callback,
view_zoomin_cmd_callback,
view_zoomout_cmd_callback,
view_zoom_16_1_callback,
view_zoom_8_1_callback,
view_zoom_4_1_callback,
view_zoom_2_1_callback,
view_zoom_1_1_callback,
view_zoom_1_2_callback,
view_zoom_1_4_callback,
view_zoom_1_8_callback,
view_zoom_1_16_callback,
view_window_info_cmd_callback,
view_toggle_rulers_cmd_callback,
view_toggle_guides_cmd_callback,
view_snap_to_guides_cmd_callback,
channel_ops_duplicate_cmd_callback,
dialogs_lc_cmd_callback,
dialogs_brushes_cmd_callback,
dialogs_patterns_cmd_callback,
dialogs_palette_cmd_callback,
dialogs_gradient_editor_cmd_callback,
dialogs_lc_cmd_callback,
dialogs_indexed_palette_cmd_callback,