Bug 729326 - Errors found using a static code analysis program cppcheck

Fixed some memory and file leaks. And removed some code and variables
that are not used.
This commit is contained in:
Rickard 2014-04-30 00:36:00 +02:00 committed by Michael Natterer
parent 26738b9ff3
commit 5ec413a5e8
10 changed files with 24 additions and 30 deletions

View File

@ -73,18 +73,8 @@ dynamics_editor_actions_update (GimpActionGroup *group,
gpointer user_data)
{
GimpDataEditor *data_editor = GIMP_DATA_EDITOR (user_data);
GimpData *data;
gboolean editable = FALSE;
gboolean edit_active = FALSE;
data = data_editor->data;
if (data)
{
if (data_editor->data_editable)
editable = TRUE;
}
edit_active = gimp_data_editor_get_edit_active (data_editor);
#define SET_SENSITIVE(action,condition) \

View File

@ -75,7 +75,7 @@ gimp_drawable_bucket_fill (GimpDrawable *drawable,
gdouble y,
GError **error)
{
GimpRGB color;
GimpRGB color = { 0, };
GimpPattern *pattern = NULL;
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);

View File

@ -495,12 +495,15 @@ plug_in_menus_build_path (GimpUIManager *manager,
gchar *menu_item_name;
menu_item_name = strrchr (parent_menu_path, '/');
*menu_item_name++ = '\0';
if (menu_item_name)
parent_action_path = plug_in_menus_build_path (manager,
ui_path, merge_id,
parent_menu_path, TRUE);
{
*menu_item_name++ = '\0';
parent_action_path = plug_in_menus_build_path (manager,
ui_path, merge_id,
parent_menu_path, TRUE);
}
if (parent_action_path)
{

View File

@ -1044,7 +1044,7 @@ gimp_vectors_bounds (GimpVectors *vectors,
vectors->bounds_empty = TRUE;
vectors->bounds_x1 = vectors->bounds_x2 = 0.0;
vectors->bounds_x1 = vectors->bounds_x2 = 0.0;
vectors->bounds_y1 = vectors->bounds_y2 = 0.0;
for (stroke = gimp_vectors_stroke_get_next (vectors, NULL);
stroke;

View File

@ -92,7 +92,7 @@ void
gimp_language_store_parser_init (void)
{
GHashTable *base_lang_list;
gchar *current_env = g_strdup (g_getenv ("LANGUAGE"));
gchar *current_env;
GDir *locales_dir;
GHashTableIter lang_iter;
gpointer key;
@ -103,6 +103,8 @@ gimp_language_store_parser_init (void)
return;
}
current_env = g_strdup (g_getenv ("LANGUAGE"));
l10n_lang_list = g_hash_table_new_full (g_str_hash, g_str_equal,
(GDestroyNotify) g_free,
(GDestroyNotify) g_free);

View File

@ -119,7 +119,6 @@ gimp_pdb_dialog_class_init (GimpPdbDialogClass *klass)
object_class->constructed = gimp_pdb_dialog_constructed;
object_class->dispose = gimp_pdb_dialog_dispose;
object_class->set_property = gimp_pdb_dialog_set_property;
object_class->set_property = gimp_pdb_dialog_set_property;
dialog_class->response = gimp_pdb_dialog_response;

View File

@ -137,7 +137,7 @@ _br_find_exe (GimpBinrelocInitError *error)
/* Get rid of newline character. */
buf_size = strlen (line);
if (buf_size <= 0) {
if (buf_size == 0) {
/* Huh? An empty string? */
fclose (f);
g_free (line);

View File

@ -114,18 +114,17 @@ main(void)
{
const gchar *test = cases[i].string;
GimpEevlQuantity should = cases[i].result;
gboolean success = FALSE;
GimpEevlQuantity result = { 0, -1 };
gboolean should_succeed = cases[i].should_succeed;
GError *error = NULL;
const gchar *error_pos = 0;
success = gimp_eevl_evaluate (test,
test_units,
&result,
NULL,
&error_pos,
&error);
gimp_eevl_evaluate (test,
test_units,
&result,
NULL,
&error_pos,
&error);
g_print ("%s = %lg (%d): ", test, result.value, result.dimension);
if (error || error_pos)

View File

@ -648,16 +648,15 @@ dx_dinput_event_dispatch (GSource *source,
GimpController *controller = &input->parent_instance;
const DIDATAFORMAT * const format = input->format;
const DIOBJECTDATAFORMAT *rgodf = format->rgodf;
HRESULT hresult;
guchar *data;
gint i;
GimpControllerEvent cevent = { 0, };
data = g_alloca (format->dwDataSize);
if (FAILED ((hresult = IDirectInputDevice8_GetDeviceState (input->didevice8,
format->dwDataSize,
data))))
if (FAILED (IDirectInputDevice8_GetDeviceState (input->didevice8,
format->dwDataSize,
data)))
{
return TRUE;
}

View File

@ -143,6 +143,7 @@ aux_window_filter (GdkXEvent *xevent,
GdkEvent *event,
gpointer data)
{
#if 0
GimpInputDeviceStore *store = (GimpInputDeviceStore *) data;
const MSG *msg = (MSG *) xevent;
@ -150,6 +151,7 @@ aux_window_filter (GdkXEvent *xevent,
switch (msg->message)
{
}
#endif
return GDK_FILTER_REMOVE;
}