• Alvaro Herrera's avatar
    Fix use-after-free bug with event triggers in an extension script · ced138e8
    Alvaro Herrera authored
    ALTER TABLE commands in an extension script are added to an event
    trigger command list; but starting with commit b5810de3 they do so in
    a memory context that's too short-lived, so when execution ends and time
    comes to use the entries, they've already been freed.
    
    (This would also be a problem with ALTER TABLE commands in a
    multi-command query string, but these serendipitously end in
    PortalContext -- which probably explains why it took so long for this to
    be reported.)
    
    Fix by using the memory context specifically set for that, instead.
    
    Backpatch to 13, where the aforementioned commit appeared.
    
    Reported-by: Philippe Beaudoin
    Author: Jehan-Guillaume de Rorthais <jgdr@dalibo.com>
    Discussion: https://postgr.es/m/20200902193715.6e0269d4@firost
    ced138e8
test_ext_evttrig.control 86 Bytes