Ticket #52281: patch-camel_camel-folder-thread.c.diff

File patch-camel_camel-folder-thread.c.diff, 937 bytes (added by gwhitney, 8 years ago)

actual patch to evolution-data-server code, in the "camel" library

  • camel/camel-folder-thread.c

    old new  
    425425                return 1;
    426426}
    427427
     428#define MAX_ALLOCA_CHILDREN 1024
     429
    428430static void
    429431sort_thread (CamelFolderThreadNode **cp)
    430432{
    431433        CamelFolderThreadNode *c, *head, **carray;
    432434        gint size = 0;
    433 
     435        gboolean need_to_free_carray = FALSE;
     436       
    434437        c = *cp;
    435438        while (c) {
    436439                /* sort the children while we're at it */
     
    441444        }
    442445        if (size < 2)
    443446                return;
    444         carray = alloca (size * sizeof (CamelFolderThreadNode *));
     447        if (size > MAX_ALLOCA_CHILDREN) {
     448                carray = g_new (CamelFolderThreadNode *, size);
     449                need_to_free_carray = TRUE;
     450        } else {
     451                carray = alloca (size * sizeof (CamelFolderThreadNode *));
     452        }
    445453        c = *cp;
    446454        size = 0;
    447455        while (c) {
     
    461469                size--;
    462470        } while (size >= 0);
    463471        *cp = head;
     472        if (need_to_free_carray) {
     473                g_free (carray);
     474        }
    464475}
    465476
    466477static guint