Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def extract_protobuf_messages(fit_bytes):
varint_decoder = google.protobuf.internal.decoder._DecodeVarint32
next_pos, pos = 0, 0
while pos < len(fit_bytes):
msg = callbacks_writer_pb2.WriterMessage()
next_pos, pos = varint_decoder(fit_bytes, pos)
msg.ParseFromString(fit_bytes[pos : pos + next_pos])
yield msg
pos += next_pos