Commit 2a90a68c authored by Moritz Lipp's avatar Moritz Lipp
Browse files

Saner solution for the possible seg fault

parent 9d5cbcab
...@@ -25,20 +25,6 @@ gboolean document_info_open(gpointer data); ...@@ -25,20 +25,6 @@ gboolean document_info_open(gpointer data);
zathura_t* zathura_t*
zathura_init(int argc, char* argv[]) zathura_init(int argc, char* argv[])
{ {
zathura_t* zathura = malloc(sizeof(zathura_t));
if (zathura == NULL) {
return NULL;
}
/* general */
zathura->document = NULL;
/* plugins */
zathura->plugins.plugins = girara_list_new();
zathura->plugins.path = girara_list_new();
girara_list_set_free_function(zathura->plugins.path, g_free);
/* parse command line options */ /* parse command line options */
GdkNativeWindow embed = 0; GdkNativeWindow embed = 0;
gchar* config_dir = NULL, *data_dir = NULL, *plugin_path = NULL; gchar* config_dir = NULL, *data_dir = NULL, *plugin_path = NULL;
...@@ -60,11 +46,24 @@ zathura_init(int argc, char* argv[]) ...@@ -60,11 +46,24 @@ zathura_init(int argc, char* argv[])
printf("Error parsing command line arguments: %s\n", error->message); printf("Error parsing command line arguments: %s\n", error->message);
g_option_context_free(context); g_option_context_free(context);
g_error_free(error); g_error_free(error);
free(zathura); goto error_free;
return NULL;
} }
g_option_context_free(context); g_option_context_free(context);
zathura_t* zathura = malloc(sizeof(zathura_t));
if (zathura == NULL) {
return NULL;
}
/* general */
zathura->document = NULL;
/* plugins */
zathura->plugins.plugins = girara_list_new();
zathura->plugins.path = girara_list_new();
girara_list_set_free_function(zathura->plugins.path, g_free);
if (config_dir) { if (config_dir) {
zathura->config.config_dir = g_strdup(config_dir); zathura->config.config_dir = g_strdup(config_dir);
} else { } else {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment