Skip to content

Commit

Permalink
Print: stop leaking printer allocated&&returned by dt_get_printer_info()
Browse files Browse the repository at this point in the history
Fixes following LeakSanitizer-detected leaks:

Direct leak of 432 byte(s) in 1 object(s) allocated from:
    #0 0x7ff04e12c74f in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x5474f)
    #1 0x7ff04df002dd in dt_get_printer_info /home/lebedevri/darktable/src/common/cups_print.c:51
    #2 0x7ff02b25d4ca
    #3 0x7ff02b261c9a
    #4 0x7ff04de9ac43 in dt_lib_load_modules /home/lebedevri/darktable/src/libs/lib.c:718
    #5 0x7ff04de9d512 in dt_lib_init /home/lebedevri/darktable/src/libs/lib.c:1008
    #6 0x7ff04dc968c7 in dt_init /home/lebedevri/darktable/src/common/darktable.c:889
    #7 0x400cb8 in main /home/lebedevri/darktable/src/main.c:24
    #8 0x7ff046501b44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b44)

Direct leak of 432 byte(s) in 1 object(s) allocated from:
    #0 0x7ff04e12c74f in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x5474f)
    #1 0x7ff04df002dd in dt_get_printer_info /home/lebedevri/darktable/src/common/cups_print.c:51
    #2 0x7ff02b25d4ca
    #3 0x7ff02b25e3b2
    #4 0x7ff04b9f0503 (/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0+0x10503)
  • Loading branch information
LebedevRI committed May 23, 2015
1 parent 4d8b468 commit 7e6db02
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/libs/print_settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ static void _set_printer(dt_lib_module_t *self, const char *printer_name)
if (!printer) return;

memcpy(&ps->prt.printer, printer, sizeof(dt_printer_info_t));
free(printer);
printer = NULL;

// if there is 0 hardware margins, set the user marging to 15mm

Expand Down Expand Up @@ -994,7 +996,7 @@ gui_init (dt_lib_module_t *self)
free(default_printer);
gtk_box_pack_start(GTK_BOX(self->widget), d->printers, TRUE, TRUE, 0);
g_signal_connect(G_OBJECT(d->printers), "value-changed", G_CALLBACK(_printer_changed), self);
g_list_free_full (printers, g_free);
g_list_free_full(printers, free);

// Add printer profile combo

Expand Down

0 comments on commit 7e6db02

Please sign in to comment.