• Join/Login
  • Business Software
  • Open Source Software
  • For Vendors
  • Blog
  • About
  • More
    • Articles
    • Create
    • SourceForge Podcast
    • Site Documentation
    • Subscribe to our Newsletter
    • Support Request
SourceForge logo
For Vendors Help Create Join Login
SourceForge logo
Business Software
Open Source Software
SourceForge Podcast
Resources
  • Articles
  • Case Studies
  • Blog
Menu
  • Help
  • Create
  • Join
  • Login
  • Home
  • Browse
  • comtypes
  • Bugs

List-index access to COM object array crashes python

Status: Beta
Brought to you by: cfarrow, jaraco, theller
  • Summary
  • Files
  • Reviews
  • Support
  • Mailing Lists
  • Tickets ▾
    • Feature Requests
    • Bugs
    • Patches
Menu ▾ ▴
  • Create Ticket
  • View Stats

Group

Searches

  • Changes
  • Closed Tickets
  • Open Tickets

Help

  • Formatting Help

#23 List-index access to COM object array crashes python

open
nobody
None
5
2014-02-19
2012-09-28
Anonymous
No

This bug happened to me a year ago so I'm a little fuzzy on exactly what happened, but it was a doozy. Here is some code that repros the bug

items = (POINTER(IWiaItem) * NUM_OBJECTS_TO_REQUEST)()
num_fetched = enum.Next(NUM_OBJECTS_TO_REQUEST, items)

print items[0]
print items[0]

where enum.Next has a signature of

COMMETHOD([], HRESULT, 'Next',
( ['in'], ULONG, 'celt'),
( ['in, out'], POINTER(POINTER(IWiaItem)), 'ppIWiaItem'),
( ['out'], POINTER(ULONG), 'pceltFetched'))

The array items is an array of IWiaItems. When you do items[0], it helpfully turns the thing into an actual IWiaItem object for you to use, but when that object is destroyed, we call __com_Release. So when you do items[0] the second time, it does Release again (and it only did AddReference once). So eventually, crash! Yay.

Another user reported same in the user reviews on https://sourceforge.net/projects/comtypes/.

Discussion

  • Christopher L Farrow

    Christopher L Farrow - 2014-02-19

    Transferred to https://github.com/enthought/comtypes/issues/21 .

     
    If you would like to refer to this comment somewhere else in this project, copy and paste the following link:

Log in to post a comment.

SourceForge
  • Create a Project
  • Open Source Software
  • Business Software
  • Top Downloaded Projects
Company
  • About
  • Team
  • SourceForge Headquarters
    1320 Columbia Street Suite 310
    San Diego, CA 92101
    +1 (858) 422-6466
Resources
  • Support
  • Site Documentation
  • Site Status
  • SourceForge Reviews
SourceForge logo
© 2026 Slashdot Media. All Rights Reserved.
Terms Privacy Opt Out Advertise
MongoDB Logo MongoDB