]> git.armaanb.net Git - chorizo.git/commitdiff
Patch leaks
authorArmaan Bhojwani <me@armaanb.net>
Thu, 10 Jun 2021 00:51:14 +0000 (20:51 -0400)
committerArmaan Bhojwani <me@armaanb.net>
Thu, 10 Jun 2021 14:14:16 +0000 (10:14 -0400)
src/browser.c

index 75bde2cba5252c376417710880ce1c05dbc5c74e..5b71040154eddf0a83accf0ca5d1e57a144e6ed5 100644 (file)
@@ -81,6 +81,8 @@ struct MainWindow {
 } mw;
 
 gint clients = 0;
 } mw;
 
 gint clients = 0;
+struct Client **client_arr;
+
 int cooperative_pipe_fp = 0;
 gchar *search_text;
 
 int cooperative_pipe_fp = 0;
 gchar *search_text;
 
@@ -294,6 +296,9 @@ client_new(const gchar *uri, WebKitWebView *related_wv, gboolean show,
     set_uri(uri, c);
 
     clients++;
     set_uri(uri, c);
 
     clients++;
+    client_arr = realloc(client_arr, (clients + 1) * sizeof(client_arr[0]));
+    client_arr[clients] = c;
+
     return WEBKIT_WEB_VIEW(c->web_view);
 }
 
     return WEBKIT_WEB_VIEW(c->web_view);
 }
 
@@ -425,9 +430,9 @@ changed_title(GObject *obj, GParamSpec *pspec, gpointer data) {
     gboolean mute = webkit_web_view_get_is_muted(WEBKIT_WEB_VIEW(c->web_view));
     gchar *muted = (mute) ? "[m] " : "";
     sprintf(name, "%s%s", muted, t);
     gboolean mute = webkit_web_view_get_is_muted(WEBKIT_WEB_VIEW(c->web_view));
     gchar *muted = (mute) ? "[m] " : "";
     sprintf(name, "%s%s", muted, t);
-
     gtk_label_set_text(GTK_LABEL(c->tablabel), name);
     g_free(name);
     gtk_label_set_text(GTK_LABEL(c->tablabel), name);
     g_free(name);
+
     gtk_widget_set_tooltip_text(c->tablabel, t);
     mainwindow_title(gtk_notebook_get_current_page(GTK_NOTEBOOK(mw.notebook)));
 }
     gtk_widget_set_tooltip_text(c->tablabel, t);
     mainwindow_title(gtk_notebook_get_current_page(GTK_NOTEBOOK(mw.notebook)));
 }
@@ -729,6 +734,7 @@ init_default_web_context(void) {
         WebKitCookiePersistentStorage type =
             WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE;
         webkit_cookie_manager_set_persistent_storage(cm, fname, type);
         WebKitCookiePersistentStorage type =
             WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE;
         webkit_cookie_manager_set_persistent_storage(cm, fname, type);
+        g_free(fname);
     }
 
     const gchar *const languages[2] = {(const gchar *)cfg.spellcheck_language,
     }
 
     const gchar *const languages[2] = {(const gchar *)cfg.spellcheck_language,
@@ -1071,6 +1077,7 @@ mainwindow_setup(void) {
     gchar *title = malloc(strlen(priv) + strlen(__NAME__) + 1);
     sprintf(title, "%s%s", __NAME__, priv);
     gtk_window_set_title(GTK_WINDOW(mw.win), title);
     gchar *title = malloc(strlen(priv) + strlen(__NAME__) + 1);
     sprintf(title, "%s%s", __NAME__, priv);
     gtk_window_set_title(GTK_WINDOW(mw.win), title);
+    g_free(title);
 
     mw.notebook = gtk_notebook_new();
     gtk_notebook_set_scrollable(GTK_NOTEBOOK(mw.notebook), TRUE);
 
     mw.notebook = gtk_notebook_new();
     gtk_notebook_set_scrollable(GTK_NOTEBOOK(mw.notebook), TRUE);
@@ -1180,17 +1187,20 @@ show_web_view(WebKitWebView *web_view, gpointer data) {
 void
 trust_user_certs(WebKitWebContext *wc) {
     GTlsCertificate *cert;
 void
 trust_user_certs(WebKitWebContext *wc) {
     GTlsCertificate *cert;
-    const gchar *basedir, *file, *absfile;
+    gchar *basedir, *absfile;
+    const gchar *file;
     GDir *dir;
 
     basedir = g_build_filename(g_get_user_data_dir(), __NAME__, "certs", NULL);
     dir = g_dir_open(basedir, 0, NULL);
     GDir *dir;
 
     basedir = g_build_filename(g_get_user_data_dir(), __NAME__, "certs", NULL);
     dir = g_dir_open(basedir, 0, NULL);
+    g_free(basedir);
     if (dir != NULL) {
         file = g_dir_read_name(dir);
         while (file != NULL) {
             absfile = g_build_filename(g_get_user_data_dir(), __NAME__, "certs",
                                        file, NULL);
             cert = g_tls_certificate_new_from_file(absfile, NULL);
     if (dir != NULL) {
         file = g_dir_read_name(dir);
         while (file != NULL) {
             absfile = g_build_filename(g_get_user_data_dir(), __NAME__, "certs",
                                        file, NULL);
             cert = g_tls_certificate_new_from_file(absfile, NULL);
+            g_free(absfile);
             if (cert == NULL)
                 fprintf(stderr, __NAME__ ": Could not load trusted cert '%s'\n",
                         file);
             if (cert == NULL)
                 fprintf(stderr, __NAME__ ": Could not load trusted cert '%s'\n",
                         file);
@@ -1209,17 +1219,16 @@ get_ini(void) {
     config = g_key_file_new();
 
     // Load user config
     config = g_key_file_new();
 
     // Load user config
-    if (!g_key_file_load_from_file(config,
-                                   g_build_filename(g_get_user_config_dir(),
-                                                    __NAME__, "chorizo.ini",
-                                                    NULL),
-                                   flags, NULL)) {
+    gchar *fname = g_build_filename(g_get_user_config_dir(), __NAME__,
+                                    "chorizo.ini", NULL);
+    if (!g_key_file_load_from_file(config, fname, flags, NULL)) {
         // Load global config
         if (!g_key_file_load_from_file(config, "/etc/chorizo.ini", flags,
                                        NULL)) {
             fprintf(stderr, "Could not load chorizo.ini");
         }
     }
         // Load global config
         if (!g_key_file_load_from_file(config, "/etc/chorizo.ini", flags,
                                        NULL)) {
             fprintf(stderr, "Could not load chorizo.ini");
         }
     }
+    g_free(fname);
     return config;
 }
 
     return config;
 }
 
@@ -1256,6 +1265,7 @@ main(int argc, char **argv) {
     downloadmanager_setup();
     mainwindow_setup();
 
     downloadmanager_setup();
     mainwindow_setup();
 
+    client_arr = malloc(sizeof(struct Client *));
     if (optind >= argc) {
         client_new(cfg.home_uri, NULL, TRUE, TRUE);
     } else {
     if (optind >= argc) {
         client_new(cfg.home_uri, NULL, TRUE, TRUE);
     } else {
@@ -1266,5 +1276,9 @@ main(int argc, char **argv) {
     if (!cfg.cooperative_instances || cfg.cooperative_alone)
         gtk_main();
 
     if (!cfg.cooperative_instances || cfg.cooperative_alone)
         gtk_main();
 
+    for (int i = 0; i < clients; i++) {
+        free(&(client_arr[i]));
+    }
+
     exit(EXIT_SUCCESS);
 }
     exit(EXIT_SUCCESS);
 }