GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Guard iAttachment.detach() against an already-released interface (1.x) · FirebirdSQL/python3-driver@375055e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src/firebird/driver
    • interfaces.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/firebird/driver/interfaces.py‎

Copy file name to clipboardExpand all lines: src/firebird/driver/interfaces.py
+9-3Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,9 +1233,15 @@ class iAttachment(iAttachment_v4):
12331233
VERSION = 5
12341234
def detach(self) -> None:
12351235
"Replaces `isc_detach_database()`. On success releases interface."
1236-
self.vtable.detach(self, self.status)
1237-
self._check()
1238-
self._refcnt -= 1
1236+
# Guard against detaching an already-released interface. During cyclic
1237+
# garbage collection the iAttachment's own iReferenceCounted.__del__
1238+
# may run release() before Connection.__del__ calls detach(); without
1239+
# this guard the native call dereferences freed memory and segfaults.
1240+
# iAttachment_v4.detach already guards the same way.
1241+
if self._refcnt:
1242+
self.vtable.detach(self, self.status)
1243+
self._check()
1244+
self._refcnt -= 1
12391245
def drop_database(self) -> None:
12401246
"Replaces `isc_drop_database()`. On success releases interface."
12411247
self.vtable.dropDatabase(self, self.status)

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.