shiyilei / protobuf-c

Automatically exported from code.google.com/p/protobuf-c
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

ByteSize() doesn't return right value #95

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.Create message:

message Message {
required bytes byteStream = 1;
}

2. Create an byte array(size256) and set byte 27 to 0x00
    char bytePatternarray[256];

    for(int i =0; i < sizeof(bytePatternarray);i++)
    {
        bytePatternarray[i] = (char)i+1;
    }
    bytePatternarray[27] = 0x00;

3. Create a message;
Protocol::MessageDefinitions::Message message;
message.set_byteStream((char*)bytePatternarray));

4. Ask message for ByteSize()
int size = message.ByteSize();

What is the expected output? What do you see instead?
Expected: size = 256
Instead:  size = 27

What version of the product are you using? On what operating system?

Protocol Buffers 2.5.0 compiler -- Windows binary
Windows 7

Please provide any additional information below.

https://developers.google.com/protocol-buffers/docs/proto 
you say:
bytes   May contain any arbitrary sequence of bytes.

Looks like it can contain any arbitrary sequence of bytes except of 0x00, what 
is essential for a byte stream.

Original issue reported on code.google.com by maiki4e...@web.de on 4 Apr 2013 at 1:06