Commit c3d53e1f authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

Merged fixes from gimp-1-2:

2001-01-14  Sven Neumann  <sven@gimp.org>

	Merged fixes from gimp-1-2:

	* app/menus.c
	* app/plug-in.c: added some sanity checks for passed string pointers
	to various public functions in an attempt to fix bug #37622.

	* plug-ins/common/sharpen.c: applied a patch from Jerome Zago
        <jzago@ifhamy.insa-lyon.fr> that fixes a longstanding bug in the
        sharpen filter which sometimes got the last line wrong.
	Fixes bug #34155.
parent cac3f7cb
2001-01-14 Sven Neumann <sven@gimp.org>
Merged fixes from gimp-1-2:
* app/menus.c
* app/plug-in.c: added some sanity checks for passed string pointers
to various public functions in an attempt to fix bug #37622.
* plug-ins/common/sharpen.c: applied a patch from Jerome Zago
<jzago@ifhamy.insa-lyon.fr> that fixes a longstanding bug in the
sharpen filter which sometimes got the last line wrong.
Fixes bug #34155.
2001-01-14 Michael Natterer <mitch@gimp.org>
* app/apptypes.h
......
......@@ -498,6 +498,8 @@ plug_in_add (gchar *prog,
PlugInProcDef *proc_def;
GSList *tmp;
g_return_if_fail (prog != NULL);
if (strncmp ("plug_in_", prog, 8) != 0)
{
gchar *t = g_strdup_printf ("plug_in_%s", prog);
......@@ -554,6 +556,8 @@ plug_in_image_types (gchar *name)
PlugInProcDef *proc_def;
GSList *tmp;
g_return_val_if_fail (name != NULL, NULL);
if (current_plug_in)
{
plug_in_def = current_plug_in->user_data;
......@@ -618,6 +622,8 @@ plug_in_file_handler (gchar *name,
PlugInProcDef *proc_def;
GSList *tmp;
g_return_val_if_fail (name != NULL, NULL);
if (current_plug_in)
{
plug_in_def = current_plug_in->user_data;
......@@ -783,6 +789,8 @@ plug_in_menu_path (gchar *name)
PlugInProcDef *proc_def;
GSList *tmp, *tmp2;
g_return_val_if_fail (name != NULL, NULL);
for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
{
plug_in_def = tmp->data;
......@@ -1764,7 +1772,8 @@ plug_in_handle_proc_return (GPProcReturn *proc_return)
blocked = tmp->data;
tmp = tmp->next;
if (strcmp (blocked->proc_name, proc_return->name) == 0)
if (blocked->proc_name && proc_return->name &&
strcmp (blocked->proc_name, proc_return->name) == 0)
{
plug_in_push (blocked->plug_in);
if (!gp_proc_return_write (current_writechannel, proc_return))
......
......@@ -855,12 +855,18 @@ menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
gpointer callback_data)
{
GtkItemFactory *item_factory;
gchar *path;
gchar *path;
g_return_if_fail (entry != NULL);
if (!menus_initialized)
menus_init ();
path = entry->entry.path;
if (!path)
return;
item_factory = gtk_item_factory_from_path (path);
if (!item_factory)
......@@ -889,6 +895,9 @@ menus_create_branches (GtkItemFactory *item_factory,
gchar *p;
gchar *path;
if (! entry->entry.path)
return;
tearoff_path = g_string_new ("");
path = entry->entry.path;
......@@ -1205,6 +1214,9 @@ menus_set_sensitive (gchar *path,
GtkItemFactory *ifactory;
GtkWidget *widget = NULL;
if (! path)
return;
if (!menus_initialized)
menus_init ();
......@@ -1354,6 +1366,8 @@ menus_last_opened_add (gchar *filename)
GtkWidget *menu_item;
guint num_entries;
g_return_if_fail (filename != NULL);
/* do nothing if we've already got the filename on the list */
for (list = last_opened_raw_filenames; list; list = g_slist_next (list))
{
......@@ -1816,7 +1830,9 @@ menu_translate (const gchar *path,
complete = g_strconcat (factory, complete, NULL);
translation = g_strdup (dgettext (domain, complete));
while (*complete && *translation && strcmp (complete, menupath))
while (complete && *complete &&
translation && *translation &&
strcmp (complete, menupath))
{
p = strrchr (complete, '/');
t = strrchr (translation, '/');
......
......@@ -498,6 +498,8 @@ plug_in_add (gchar *prog,
PlugInProcDef *proc_def;
GSList *tmp;
g_return_if_fail (prog != NULL);
if (strncmp ("plug_in_", prog, 8) != 0)
{
gchar *t = g_strdup_printf ("plug_in_%s", prog);
......@@ -554,6 +556,8 @@ plug_in_image_types (gchar *name)
PlugInProcDef *proc_def;
GSList *tmp;
g_return_val_if_fail (name != NULL, NULL);
if (current_plug_in)
{
plug_in_def = current_plug_in->user_data;
......@@ -618,6 +622,8 @@ plug_in_file_handler (gchar *name,
PlugInProcDef *proc_def;
GSList *tmp;
g_return_val_if_fail (name != NULL, NULL);
if (current_plug_in)
{
plug_in_def = current_plug_in->user_data;
......@@ -783,6 +789,8 @@ plug_in_menu_path (gchar *name)
PlugInProcDef *proc_def;
GSList *tmp, *tmp2;
g_return_val_if_fail (name != NULL, NULL);
for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
{
plug_in_def = tmp->data;
......@@ -1764,7 +1772,8 @@ plug_in_handle_proc_return (GPProcReturn *proc_return)
blocked = tmp->data;
tmp = tmp->next;
if (strcmp (blocked->proc_name, proc_return->name) == 0)
if (blocked->proc_name && proc_return->name &&
strcmp (blocked->proc_name, proc_return->name) == 0)
{
plug_in_push (blocked->plug_in);
if (!gp_proc_return_write (current_writechannel, proc_return))
......
......@@ -498,6 +498,8 @@ plug_in_add (gchar *prog,
PlugInProcDef *proc_def;
GSList *tmp;
g_return_if_fail (prog != NULL);
if (strncmp ("plug_in_", prog, 8) != 0)
{
gchar *t = g_strdup_printf ("plug_in_%s", prog);
......@@ -554,6 +556,8 @@ plug_in_image_types (gchar *name)
PlugInProcDef *proc_def;
GSList *tmp;
g_return_val_if_fail (name != NULL, NULL);
if (current_plug_in)
{
plug_in_def = current_plug_in->user_data;
......@@ -618,6 +622,8 @@ plug_in_file_handler (gchar *name,
PlugInProcDef *proc_def;
GSList *tmp;
g_return_val_if_fail (name != NULL, NULL);
if (current_plug_in)
{
plug_in_def = current_plug_in->user_data;
......@@ -783,6 +789,8 @@ plug_in_menu_path (gchar *name)
PlugInProcDef *proc_def;
GSList *tmp, *tmp2;
g_return_val_if_fail (name != NULL, NULL);
for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
{
plug_in_def = tmp->data;
......@@ -1764,7 +1772,8 @@ plug_in_handle_proc_return (GPProcReturn *proc_return)
blocked = tmp->data;
tmp = tmp->next;
if (strcmp (blocked->proc_name, proc_return->name) == 0)
if (blocked->proc_name && proc_return->name &&
strcmp (blocked->proc_name, proc_return->name) == 0)
{
plug_in_push (blocked->plug_in);
if (!gp_proc_return_write (current_writechannel, proc_return))
......
......@@ -855,12 +855,18 @@ menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
gpointer callback_data)
{
GtkItemFactory *item_factory;
gchar *path;
gchar *path;
g_return_if_fail (entry != NULL);
if (!menus_initialized)
menus_init ();
path = entry->entry.path;
if (!path)
return;
item_factory = gtk_item_factory_from_path (path);
if (!item_factory)
......@@ -889,6 +895,9 @@ menus_create_branches (GtkItemFactory *item_factory,
gchar *p;
gchar *path;
if (! entry->entry.path)
return;
tearoff_path = g_string_new ("");
path = entry->entry.path;
......@@ -1205,6 +1214,9 @@ menus_set_sensitive (gchar *path,
GtkItemFactory *ifactory;
GtkWidget *widget = NULL;
if (! path)
return;
if (!menus_initialized)
menus_init ();
......@@ -1354,6 +1366,8 @@ menus_last_opened_add (gchar *filename)
GtkWidget *menu_item;
guint num_entries;
g_return_if_fail (filename != NULL);
/* do nothing if we've already got the filename on the list */
for (list = last_opened_raw_filenames; list; list = g_slist_next (list))
{
......@@ -1816,7 +1830,9 @@ menu_translate (const gchar *path,
complete = g_strconcat (factory, complete, NULL);
translation = g_strdup (dgettext (domain, complete));
while (*complete && *translation && strcmp (complete, menupath))
while (complete && *complete &&
translation && *translation &&
strcmp (complete, menupath))
{
p = strrchr (complete, '/');
t = strrchr (translation, '/');
......
......@@ -855,12 +855,18 @@ menus_create_item_from_full_path (GimpItemFactoryEntry *entry,
gpointer callback_data)
{
GtkItemFactory *item_factory;
gchar *path;
gchar *path;
g_return_if_fail (entry != NULL);
if (!menus_initialized)
menus_init ();
path = entry->entry.path;
if (!path)
return;
item_factory = gtk_item_factory_from_path (path);
if (!item_factory)
......@@ -889,6 +895,9 @@ menus_create_branches (GtkItemFactory *item_factory,
gchar *p;
gchar *path;
if (! entry->entry.path)
return;
tearoff_path = g_string_new ("");
path = entry->entry.path;
......@@ -1205,6 +1214,9 @@ menus_set_sensitive (gchar *path,
GtkItemFactory *ifactory;
GtkWidget *widget = NULL;
if (! path)
return;
if (!menus_initialized)
menus_init ();
......@@ -1354,6 +1366,8 @@ menus_last_opened_add (gchar *filename)
GtkWidget *menu_item;
guint num_entries;
g_return_if_fail (filename != NULL);
/* do nothing if we've already got the filename on the list */
for (list = last_opened_raw_filenames; list; list = g_slist_next (list))
{
......@@ -1816,7 +1830,9 @@ menu_translate (const gchar *path,
complete = g_strconcat (factory, complete, NULL);
translation = g_strdup (dgettext (domain, complete));
while (*complete && *translation && strcmp (complete, menupath))
while (complete && *complete &&
translation && *translation &&
strcmp (complete, menupath))
{
p = strrchr (complete, '/');
t = strrchr (translation, '/');
......
......@@ -498,6 +498,8 @@ plug_in_add (gchar *prog,
PlugInProcDef *proc_def;
GSList *tmp;
g_return_if_fail (prog != NULL);
if (strncmp ("plug_in_", prog, 8) != 0)
{
gchar *t = g_strdup_printf ("plug_in_%s", prog);
......@@ -554,6 +556,8 @@ plug_in_image_types (gchar *name)
PlugInProcDef *proc_def;
GSList *tmp;
g_return_val_if_fail (name != NULL, NULL);
if (current_plug_in)
{
plug_in_def = current_plug_in->user_data;
......@@ -618,6 +622,8 @@ plug_in_file_handler (gchar *name,
PlugInProcDef *proc_def;
GSList *tmp;
g_return_val_if_fail (name != NULL, NULL);
if (current_plug_in)
{
plug_in_def = current_plug_in->user_data;
......@@ -783,6 +789,8 @@ plug_in_menu_path (gchar *name)
PlugInProcDef *proc_def;
GSList *tmp, *tmp2;
g_return_val_if_fail (name != NULL, NULL);
for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
{
plug_in_def = tmp->data;
......@@ -1764,7 +1772,8 @@ plug_in_handle_proc_return (GPProcReturn *proc_return)
blocked = tmp->data;
tmp = tmp->next;
if (strcmp (blocked->proc_name, proc_return->name) == 0)
if (blocked->proc_name && proc_return->name &&
strcmp (blocked->proc_name, proc_return->name) == 0)
{
plug_in_push (blocked->plug_in);
if (!gp_proc_return_write (current_writechannel, proc_return))
......
......@@ -498,6 +498,8 @@ plug_in_add (gchar *prog,
PlugInProcDef *proc_def;
GSList *tmp;
g_return_if_fail (prog != NULL);
if (strncmp ("plug_in_", prog, 8) != 0)
{
gchar *t = g_strdup_printf ("plug_in_%s", prog);
......@@ -554,6 +556,8 @@ plug_in_image_types (gchar *name)
PlugInProcDef *proc_def;
GSList *tmp;
g_return_val_if_fail (name != NULL, NULL);
if (current_plug_in)
{
plug_in_def = current_plug_in->user_data;
......@@ -618,6 +622,8 @@ plug_in_file_handler (gchar *name,
PlugInProcDef *proc_def;
GSList *tmp;
g_return_val_if_fail (name != NULL, NULL);
if (current_plug_in)
{
plug_in_def = current_plug_in->user_data;
......@@ -783,6 +789,8 @@ plug_in_menu_path (gchar *name)
PlugInProcDef *proc_def;
GSList *tmp, *tmp2;
g_return_val_if_fail (name != NULL, NULL);
for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
{
plug_in_def = tmp->data;
......@@ -1764,7 +1772,8 @@ plug_in_handle_proc_return (GPProcReturn *proc_return)
blocked = tmp->data;
tmp = tmp->next;
if (strcmp (blocked->proc_name, proc_return->name) == 0)
if (blocked->proc_name && proc_return->name &&
strcmp (blocked->proc_name, proc_return->name) == 0)
{
plug_in_push (blocked->plug_in);
if (!gp_proc_return_write (current_writechannel, proc_return))
......
......@@ -498,6 +498,8 @@ plug_in_add (gchar *prog,
PlugInProcDef *proc_def;
GSList *tmp;
g_return_if_fail (prog != NULL);
if (strncmp ("plug_in_", prog, 8) != 0)
{
gchar *t = g_strdup_printf ("plug_in_%s", prog);
......@@ -554,6 +556,8 @@ plug_in_image_types (gchar *name)
PlugInProcDef *proc_def;
GSList *tmp;
g_return_val_if_fail (name != NULL, NULL);
if (current_plug_in)
{
plug_in_def = current_plug_in->user_data;
......@@ -618,6 +622,8 @@ plug_in_file_handler (gchar *name,
PlugInProcDef *proc_def;
GSList *tmp;
g_return_val_if_fail (name != NULL, NULL);
if (current_plug_in)
{
plug_in_def = current_plug_in->user_data;
......@@ -783,6 +789,8 @@ plug_in_menu_path (gchar *name)
PlugInProcDef *proc_def;
GSList *tmp, *tmp2;
g_return_val_if_fail (name != NULL, NULL);
for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
{
plug_in_def = tmp->data;
......@@ -1764,7 +1772,8 @@ plug_in_handle_proc_return (GPProcReturn *proc_return)
blocked = tmp->data;
tmp = tmp->next;
if (strcmp (blocked->proc_name, proc_return->name) == 0)
if (blocked->proc_name && proc_return->name &&
strcmp (blocked->proc_name, proc_return->name) == 0)
{
plug_in_push (blocked->plug_in);
if (!gp_proc_return_write (current_writechannel, proc_return))
......
......@@ -498,6 +498,8 @@ plug_in_add (gchar *prog,
PlugInProcDef *proc_def;
GSList *tmp;
g_return_if_fail (prog != NULL);
if (strncmp ("plug_in_", prog, 8) != 0)
{
gchar *t = g_strdup_printf ("plug_in_%s", prog);
......@@ -554,6 +556,8 @@ plug_in_image_types (gchar *name)
PlugInProcDef *proc_def;
GSList *tmp;
g_return_val_if_fail (name != NULL, NULL);
if (current_plug_in)
{
plug_in_def = current_plug_in->user_data;
......@@ -618,6 +622,8 @@ plug_in_file_handler (gchar *name,
PlugInProcDef *proc_def;
GSList *tmp;
g_return_val_if_fail (name != NULL, NULL);
if (current_plug_in)
{
plug_in_def = current_plug_in->user_data;
......@@ -783,6 +789,8 @@ plug_in_menu_path (gchar *name)
PlugInProcDef *proc_def;
GSList *tmp, *tmp2;
g_return_val_if_fail (name != NULL, NULL);
for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
{
plug_in_def = tmp->data;
......@@ -1764,7 +1772,8 @@ plug_in_handle_proc_return (GPProcReturn *proc_return)
blocked = tmp->data;
tmp = tmp->next;
if (strcmp (blocked->proc_name, proc_return->name) == 0)
if (blocked->proc_name && proc_return->name &&
strcmp (blocked->proc_name, proc_return->name) == 0)
{
plug_in_push (blocked->plug_in);
if (!gp_proc_return_write (current_writechannel, proc_return))
......
......@@ -498,6 +498,8 @@ plug_in_add (gchar *prog,
PlugInProcDef *proc_def;
GSList *tmp;
g_return_if_fail (prog != NULL);
if (strncmp ("plug_in_", prog, 8) != 0)
{
gchar *t = g_strdup_printf ("plug_in_%s", prog);
......@@ -554,6 +556,8 @@ plug_in_image_types (gchar *name)
PlugInProcDef *proc_def;
GSList *tmp;
g_return_val_if_fail (name != NULL, NULL);
if (current_plug_in)
{
plug_in_def = current_plug_in->user_data;
......@@ -618,6 +622,8 @@ plug_in_file_handler (gchar *name,
PlugInProcDef *proc_def;
GSList *tmp;
g_return_val_if_fail (name != NULL, NULL);
if (current_plug_in)
{
plug_in_def = current_plug_in->user_data;
......@@ -783,6 +789,8 @@ plug_in_menu_path (gchar *name)
PlugInProcDef *proc_def;
GSList *tmp, *tmp2;
g_return_val_if_fail (name != NULL, NULL);
for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
{
plug_in_def = tmp->data;
......@@ -1764,7 +1772,8 @@ plug_in_handle_proc_return (GPProcReturn *proc_return)
blocked = tmp->data;
tmp = tmp->next;
if (strcmp (blocked->proc_name, proc_return->name) == 0)
if (blocked->proc_name && proc_return->name &&
strcmp (blocked->proc_name, proc_return->name) == 0)
{
plug_in_push (blocked->plug_in);
if (!gp_proc_return_write (current_writechannel, proc_return))
......
......@@ -498,6 +498,8 @@ plug_in_add (gchar *prog,
PlugInProcDef *proc_def;
GSList *tmp;
g_return_if_fail (prog != NULL);
if (strncmp ("plug_in_", prog, 8) != 0)
{
gchar *t = g_strdup_printf ("plug_in_%s", prog);
......@@ -554,6 +556,8 @@ plug_in_image_types (gchar *name)
PlugInProcDef *proc_def;
GSList *tmp;
g_return_val_if_fail (name != NULL, NULL);
if (current_plug_in)
{
plug_in_def = current_plug_in->user_data;
......@@ -618,6 +622,8 @@ plug_in_file_handler (gchar *name,
PlugInProcDef *proc_def;
GSList *tmp;
g_return_val_if_fail (name != NULL, NULL);
if (current_plug_in)
{
plug_in_def = current_plug_in->user_data;
......@@ -783,6 +789,8 @@ plug_in_menu_path (gchar *name)
PlugInProcDef *proc_def;
GSList *tmp, *tmp2;
g_return_val_if_fail (name != NULL, NULL);
for (tmp = plug_in_defs; tmp; tmp = g_slist_next (tmp))
{
plug_in_def = tmp->data;
......@@ -1764,7 +1772,8 @@ plug_in_handle_proc_return (GPProcReturn *proc_return)
blocked = tmp->data;
tmp = tmp->next;
if (strcmp (blocked->proc_name, proc_return->name) == 0)
if (blocked->proc_name && proc_return->name &&
strcmp (blocked->proc_name, proc_return->name) == 0)
{
plug_in_push (blocked->plug_in);
if (!gp_proc_return_write (current_writechannel, proc_return))
......
......@@ -498,6 +498,8 @@ plug_in_add (gchar *prog,
PlugInProcDef *proc_def;
GSList *tmp;
g_return_if_fail (prog != NULL);
if (strncmp ("plug_in_", prog, 8) != 0)
{
gchar *t = g_strdup_printf ("plug_in_%s", prog);
......@@ -554,6 +556,8 @@ plug_in_image_types (gchar *name)
PlugInProcDef *proc_def;
GSList *tmp;
g_return_val_if_fail (name != NULL, NULL);
if (current_plug_in)
{
plug_in_def = current_plug_in->user_data;
......@@ -618,6 +622,8 @@ plug_in_file_handler (gchar *name,
PlugInProcDef *proc_def;
GSList *tmp;
g_return_val_if_fail (name != NULL, NULL);
if (current_plug_in)
{
plug_in_def = current_plug_in->user_data;
......@@ -783,6 +789,8 @@ plug_in_menu_path (gchar *name)
PlugInProcDef *proc_def;
GSList *tmp, *tmp2;
g_return_val_if_fail (name != NULL, NULL);