Add buffer size check in test_decode1.c example.

This check gives a better error message in case you test stuff
and have a message longer than 512 bytes.

Update issue 34
Status: FixedInGit
This commit is contained in:
Petteri Aimonen
2012-09-18 16:48:43 +03:00
parent b214de4e1e
commit 3f563792ad

View File

@@ -63,6 +63,12 @@ int main()
uint8_t buffer[512];
size_t count = fread(buffer, 1, sizeof(buffer), stdin);
if (!feof(stdin))
{
printf("Message does not fit in buffer\n");
return 1;
}
/* Construct a pb_istream_t for reading from the buffer */
pb_istream_t stream = pb_istream_from_buffer(buffer, count);