summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2012-09-18 16:48:43 +0300
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2012-09-18 16:51:22 +0300
commit3f563792adb8448a55c3b4f16f11a3b0d37dac37 (patch)
treeafbfb821804dfdc9db1c6c3886c6d6937d03909a /tests
parentb214de4e1e53f14354db36b8f199db6177a63744 (diff)
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
Diffstat (limited to 'tests')
-rw-r--r--tests/test_decode1.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/test_decode1.c b/tests/test_decode1.c
index 64eb4689..56bbd8f8 100644
--- a/tests/test_decode1.c
+++ b/tests/test_decode1.c
@@ -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);