Fix access to unallocated memory in IAsyncPG
authorCraig Ringer <craig@2ndquadrant.com>
Mon, 16 Jun 2014 13:16:31 +0000 (21:16 +0800)
committerCraig Ringer <craig@2ndquadrant.com>
Mon, 16 Jun 2014 13:16:31 +0000 (21:16 +0800)
commitdb413945da7ef668b86811c0df507cb6931090a1
tree2c48d90e1a78a2f3683471b89d5b4796c4bfa0a6
parent4658ccd9b1bb6575c2331bd184ca6c1d76782361
Fix access to unallocated memory in IAsyncPG

IAsyncPG was deleting its self, then returning an instance variable
by value. This is probably going to be safe pretty much all the time,
but it's still a memory error, and DrMemory (a Windows valgrind-alike)
complains about it:

Error #4: UNADDRESSABLE ACCESS: reading 0x00b1b2b0-0x00b1b2b4 4 byte(s)
# 0 pgenlista.dll!IAsyncPG::Release   [c:\users\administrator\desktop\psqlodbc\msdtc_enlist.cpp:352]
# 1 pgenlista.dll!CloseCommitThread   [c:\users\administrator\desktop\psqlodbc\msdtc_enlist.cpp:971]
# 2 MSVCR120D.dll!_callthreadstart    [f:\dd\vctools\crt\crtw32\startup\thread.c:255]
# 3 MSVCR120D.dll!_threadstart        [f:\dd\vctools\crt\crtw32\startup\thread.c:237]
# 4 KERNEL32.dll!BaseThreadInitThunk +0x11     (0x7768338a <KERNEL32.dll+0x1338a>)
Note: @0:00:57.879 in thread 4516
Note: next higher malloc: 0x00b1b420-0x00b1b440
Note: 0x00b1b2b0-0x00b1b2b4 overlaps memory 0x00b1b2a0-0x00b1b390 that was freed here:
Note: # 0 replace_operator_delete                              [d:\drmemory_package\common\alloc_replace.c:2524]
Note: # 1 pgenlista.dll!IAsyncPG::`scalar deleting destructor'
Note: # 2 pgenlista.dll!IAsyncPG::Release                      [c:\users\administrator\desktop\psqlodbc\msdtc_enlist.cpp:341]
Note: # 3 pgenlista.dll!CloseCommitThread                      [c:\users\administrator\desktop\psqlodbc\msdtc_enlist.cpp:971]
Note: # 4 MSVCR120D.dll!_callthreadstart                       [f:\dd\vctools\crt\crtw32\startup\thread.c:255]
Note: # 5 MSVCR120D.dll!_threadstart                           [f:\dd\vctools\crt\crtw32\startup\thread.c:237]
Note: # 6 KERNEL32.dll!BaseThreadInitThunk                    +0x11     (0x7768338a <KERNEL32.dll+0x1338a>)
Note: instruction: mov    0x10(%eax) -> %eax

This patch fixes the issue.
msdtc_enlist.cpp