Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug hunting #125

Closed
wants to merge 11 commits into from
3 changes: 2 additions & 1 deletion debugger/src/dbm_gdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -755,10 +755,11 @@ static gboolean run(const gchar* file, const gchar* commandline, GList* env, GLi
for (iter = lines; iter; iter = iter->next)
{
gchar *unescaped = g_strcompress((gchar*)iter->data);
if (strlen(unescaped))
if (unescaped && strlen(unescaped))
{
colorize_message((gchar*)iter->data);
}
g_free(unescaped);
}
g_list_foreach(lines, (GFunc)g_free, NULL);
g_list_free(lines);
Expand Down
1 change: 1 addition & 0 deletions debugger/src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,7 @@ void debug_init(void)
config = g_key_file_new();
configfile = g_strconcat(geany_data->app->configdir, G_DIR_SEPARATOR_S, "geany.conf", NULL);
g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL);
g_free(configfile);
font = utils_get_setting_string(config, "VTE", "font", "Monospace 10");
vte_terminal_set_font_from_string (VTE_TERMINAL(terminal), font);

Expand Down
6 changes: 5 additions & 1 deletion debugger/src/tpage.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ static void on_target_browse_clicked(GtkButton *button, gpointer user_data)
if (strcmp(".", prevdir))
strcpy(path, prevdir);
else
strcpy(path, g_path_get_dirname(DOC_FILENAME(document_get_current())));
{
gchar *dirname = g_path_get_dirname(DOC_FILENAME(document_get_current()));
strcpy(path, dirname);
g_free(dirname);
}
g_free(prevdir);

gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER (dialog), path);
Expand Down
4 changes: 2 additions & 2 deletions devhelp/devhelp/ige-conf-mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,10 @@ ige_conf_notify_add (IgeConf *conf,

priv = GET_PRIVATE (conf);

data = g_slice_new (IgeConfNotifyData);
/*data = g_slice_new (IgeConfNotifyData);
data->func = func;
data->user_data = user_data;
data->conf = g_object_ref (conf);
data->conf = g_object_ref (conf);*/

id = 0; /*gconf_client_notify_add (priv->gconf_client,
key,
Expand Down
11 changes: 7 additions & 4 deletions geanylua/glspi_dlg.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,11 @@ static gchar *file_dlg(lua_State* L, gboolean save, const gchar *path, const gch
if (name && *name) {
if (g_path_is_absolute(name)) {
fullname=g_strdup(name);
} else if (path) {fullname=g_build_filename(path,name,NULL);}
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dlg), fullname);
if (save) gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dlg), name);
} else if (path) {
fullname=g_build_filename(path,name,NULL);
}
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dlg), fullname);
if (save) { gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dlg), name); }
}
if (path && *path) {
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dlg), path);
Expand All @@ -437,6 +439,7 @@ static gchar *file_dlg(lua_State* L, gboolean save, const gchar *path, const gch
"failed to parse filter string at argument #3.\n"),
LUA_MODULE_NAME);
lua_error(L);
g_free(fullname);
return NULL;
}

Expand All @@ -454,7 +457,7 @@ static gchar *file_dlg(lua_State* L, gboolean save, const gchar *path, const gch
rv=gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dlg));
}
gtk_widget_destroy(dlg);
if (fullname) {g_free(fullname);}
g_free(fullname);
return rv;
}

Expand Down
4 changes: 2 additions & 2 deletions geanysendmail/src/geanysendmail.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ send_as_attachment(G_GNUC_UNUSED GtkMenuItem *menuitem, G_GNUC_UNUSED gpointer g
}
else
{
g_free(cmd_str);
g_string_free(cmd_str, TRUE);
g_free(locale_filename);
return;
}
Expand Down Expand Up @@ -173,7 +173,7 @@ send_as_attachment(G_GNUC_UNUSED GtkMenuItem *menuitem, G_GNUC_UNUSED gpointer g
ui_set_statusbar(FALSE, _("File has to be saved before sending."));
}

g_free(config);
g_key_file_free(config);
}

static void key_send_as_attachment(G_GNUC_UNUSED guint key_id)
Expand Down
4 changes: 3 additions & 1 deletion geanyvc/src/externdiff.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ get_external_diff_viewer(void)

for (i = 0; i < EXTERNAL_DIFF_COUNT; i++)
{
if (g_find_program_in_path(viewers[i]))
gchar *path = g_find_program_in_path(viewers[i]);
if (path)
{
g_free(path);
extern_diff_viewer = (gchar *) viewers[i];
return viewers[i];
}
Expand Down
1 change: 1 addition & 0 deletions geniuspaste/src/geniuspaste.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ static void paste(GeanyDocument * doc, const gchar * website)
if (f_content == NULL || f_content[0] == '\0')
{
dialogs_show_msgbox(GTK_MESSAGE_ERROR, _("Refusing to create blank paste"));
g_free(f_title);
return;
}

Expand Down
6 changes: 3 additions & 3 deletions gproject/src/gproject-project.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,9 +345,9 @@ void gprj_project_open(GKeyFile * key_file)
ignored_dirs_patterns,
generate_tags);

g_free(source_patterns);
g_free(header_patterns);
g_free(ignored_dirs_patterns);
g_strfreev(source_patterns);
g_strfreev(header_patterns);
g_strfreev(ignored_dirs_patterns);
}


Expand Down
8 changes: 2 additions & 6 deletions markdown/src/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,15 +447,11 @@ markdown_config_save(MarkdownConfig *conf)
gboolean success = FALSE;
GError *error = NULL;

contents = g_key_file_to_data(conf->priv->kf, &len, &error);
contents = g_key_file_to_data(conf->priv->kf, &len, NULL);

/*g_debug("Saving: %s\n%s", conf->priv->filename, contents);*/

if (error) {
g_warning("Error getting config data as string: %s", error->message);
g_error_free(error); error = NULL;
return success;
}
g_return_val_if_fail(contents, success);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong IMO. The g_return_* functions are for programmer errors. Here, this is a runtime error.
Also, I do not see any benefit of removing the error message.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding to documentation on function g_key_file_to_data:

Note that this function never reports an error, so it is safe to pass NULL as error.

So it's ok to remove dead code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, but it's also useless to add the check -- this function never returns NULL either. And as @sardemff7 said, it's kinda weird to use g_return_if_fail() here, which is supposed to be used to check for programming errors like incorrect parameters -- ok, here it checks that g_key_file_to_data() isn't buggy, but huh. IMHO, either leave it as is with the useless error checking, or remote the thing entirely.


success = g_file_set_contents(conf->priv->filename, contents, len, &error);
g_free(contents);
Expand Down
2 changes: 2 additions & 0 deletions treebrowser/src/treebrowser.c
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@ treebrowser_load_bookmarks(void)
gtk_tree_path_free(tree_path);
}
}
g_free(bookmarks);
}

static gboolean
Expand Down Expand Up @@ -756,6 +757,7 @@ fs_remove(gchar *root, gboolean delete_root)
g_free(path);
name = g_dir_read_name(dir);
}
g_dir_close(dir);
}
else
delete_root = TRUE;
Expand Down