Astron / Bamboo

[Work In Progress] A library and tools for object-oriented network protocols.
https://astron.github.io/bamboo
Other
3 stars 4 forks source link

Memory issues with DatagramIterator and bindings #1

Open kestred opened 10 years ago

kestred commented 10 years ago

When constructing a DatagramIterator from a Datagram, the DatagramIterator incorrectly reports its own remaining size.

Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.

# Correct behavior!!!
>>> from bamboo.wire import *
>>> dg = Datagram()
>>> dgi = DatagramIterator(dg)
>>> dgi.remaining()
0L

# Weird memory issues
>>> dg = DatagramIterator(Datagram())
>>> dg.remaining()
100L
>>> dg.read_bool()
True
>>> dg.remaining()
99L
>>> dg.read_bool()
False
>>> dg.remaining()
22473L
>>> dg.tell()
2L
>>> dgi = DatagramIterator(Datagram())
>>> dgi.remaining()
22475L
>>> dgi.remaining()
100L
>>> dgi.remaining()
446L
>>> dgi.remaining()
100L
>>> dgi.remaining()
22475L
>>> dgi.remaining()
100L
>>>