Skip to content

Commit fdd75ca

Browse files
authored
Merge pull request #1499 from beamerblvd/fix-configentry-memory-safety
Refactor ConfigEntry and related iterators for safer memory management
2 parents dd2cb57 + 93d1a4c commit fdd75ca

8 files changed

Lines changed: 377 additions & 106 deletions

File tree

‎AUTHORS.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ Authors:
212212
Michał Górny
213213
Mukunda Rao Katta
214214
Na'aman Hirschfeld
215+
Nicholas Williams
215216
Nicolas Rybowski
216217
Nicolás Sanguinetti
217218
Nikita Kartashov

‎pygit2/_build.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,13 @@ def get_libgit2_paths() -> tuple[Path, dict[str, list[str]]]:
7070
'libraries': ['git2'],
7171
'include_dirs': [str(x) for x in include_dirs],
7272
'library_dirs': [str(x) for x in library_dirs],
73+
# For debugging memory issues (segfaults) during development, uncomment the
74+
# following lines and rebuild everything. YMMV
75+
# 'extra_compile_args': [
76+
# '-fsanitize=address',
77+
# '-fsanitize-address-use-after-scope',
78+
# '-fsanitize-address-use-odr-indicator',
79+
# ],
80+
# 'extra_link_args': ['-fsanitize=address'],
7381
},
7482
)

‎pygit2/_run.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@
2424
# Boston, MA 02110-1301, USA.
2525

2626
"""
27-
This is an special module, it provides stuff used by by pygit2 at run-time.
27+
This is a special module, it provides stuff used by pygit2 at run-time.
2828
"""
2929

3030
# Import from the Standard Library
31-
import codecs
3231
import sys
3332
from pathlib import Path
3433

@@ -89,9 +88,8 @@
8988
]
9089
h_source = []
9190
for h_file in h_files:
92-
h_file = dir_path / 'decl' / h_file # type: ignore
93-
with codecs.open(h_file, 'r', 'utf-8') as f:
94-
h_source.append(f.read())
91+
h_path = dir_path / 'decl' / h_file
92+
h_source.append(h_path.read_text(encoding='utf-8'))
9593

9694
C_HEADER_SRC = '\n'.join(h_source)
9795

0 commit comments

Comments
 (0)