Skip to content

Commit

Permalink
Fix overflow when computing seek position
Browse files Browse the repository at this point in the history
  • Loading branch information
adamreeve committed Nov 19, 2024
1 parent d2cddeb commit 630e917
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions nptdms/tdms_segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,11 @@ def read_raw_data_for_channel(self, f, channel_path, chunk_offset=0, num_chunks=
data_objects = [o for o in self.ordered_objects if o.has_data]
chunk_size = self._get_chunk_size()

# Ensure we're working with Python ints as np.int32 values could overflow
# (https://github.com/adamreeve/npTDMS/issues/338)
chunk_size = int(chunk_size)
chunk_offset = int(chunk_offset)

if chunk_offset > 0:
f.seek(chunk_size * chunk_offset, os.SEEK_CUR)
stop_chunk = self.num_chunks if num_chunks is None else num_chunks + chunk_offset
Expand Down

0 comments on commit 630e917

Please sign in to comment.