]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/1.36.2-tray-monitor-memleak.patch
- Landon Fuller committed his TLS patch.
[bacula/bacula] / bacula / patches / 1.36.2-tray-monitor-memleak.patch
1  
2  This patch should fix memory leaks in tray-monitor.
3  Apply the patch to 1.36.2 with:
4
5  cd <bacula-source>/src/tray-monitor
6  patch -p0 <1.36.2-tray-monitor-memleak.patch
7  make
8  ...
9
10 Index: tray-monitor.c
11 ===================================================================
12 RCS file: /cvsroot/bacula/bacula/src/tray-monitor/tray-monitor.c,v
13 retrieving revision 1.19
14 diff -r1.19 tray-monitor.c
15 36a37,38
16 > #define TRAY_DEBUG_MEMORY 0
17
18 50d51
19 < static POOLMEM *args;
20 135a137,157
21 > int sm_line = 0;
22
23 > #if TRAY_DEBUG_MEMORY
24 > gpointer smt_malloc(gsize    n_bytes) {
25 >    return sm_malloc("GLib", sm_line, n_bytes);
26 > }
27 >   
28 > gpointer smt_realloc(gpointer mem, gsize    n_bytes) {
29 >    return sm_realloc("GLib", sm_line, mem, n_bytes);
30 > }
31
32 > gpointer smt_calloc(gsize    n_blocks,
33 >                     gsize    n_block_bytes) {
34 >    return sm_calloc("GLib", sm_line, n_blocks, n_block_bytes);
35 > }
36
37 > void     smt_free(gpointer mem) {
38 >    sm_free("Glib", sm_line, mem);
39 > }
40 > #endif
41
42 142a165,175
43 > #if TRAY_DEBUG_MEMORY
44 >    GMemVTable smvtable;
45 >    smvtable.malloc = &smt_malloc;
46 >    smvtable.realloc = &smt_realloc;
47 >    smvtable.free = &smt_free;
48 >    smvtable.calloc = &smt_calloc;
49 >    smvtable.try_malloc = NULL;
50 >    smvtable.try_realloc = NULL;
51 >    g_mem_set_vtable(&smvtable);
52 > #endif
53 >    
54 154d186
55 <    args = get_pool_memory(PM_FNAME);
56 255c287
57 <       g_assert((xpm_generic_var[i] = (char*)g_malloc(strlen(xpm_generic[i])*sizeof(char))));
58 ---
59 >       g_assert((xpm_generic_var[i] = (char*)g_malloc((strlen(xpm_generic[i])+1)*sizeof(char))));
60 412a445,448
61 >    
62 >    g_source_remove(timerTag);
63 >    
64 >    sm_line = 0;
65 422d457
66 <    free_pool_memory(args);
67 429a465,468
68 >    
69 >    gtk_object_destroy(GTK_OBJECT(window));
70 >    gtk_object_destroy(GTK_OBJECT(mTrayMenu));
71 >    term_msg();
72 430a470,473
73 > #if TRAY_DEBUG_MEMORY
74 >    sm_dump(false);
75 > #endif
76 >    
77 534c577,581
78 <    GtkTextBuffer *newbuffer = gtk_text_buffer_new(NULL);
79 ---
80 >    sm_line++;
81 > #if TRAY_DEBUG_MEMORY
82 >    printf("sm_line=%d\n", sm_line);
83 > #endif
84 >    GtkTextBuffer *newbuffer;
85 546a594,595
86 >       newbuffer = gtk_text_buffer_new(NULL);
87 >       
88 558a608,609
89 >       g_slist_free(list);
90 >             
91 963a1015
92 >    g_object_unref(G_OBJECT(pixbuf));