summaryrefslogtreecommitdiffstats
path: root/libs/nanopb/tests/regression/issue_205
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-06-20 10:24:05 +0000
committerRomain Forlot <romain.forlot@iot.bzh>2017-06-20 10:24:05 +0000
commit32e25cbca210a359b09768537b6f443fe90a3070 (patch)
tree3309794c15d8a8f8e9c1c08cad072ee1378813ba /libs/nanopb/tests/regression/issue_205
parent76c43dec62b2e21cd6446360c00d4fe6b437533f (diff)
Separation Generator to a dedicated repo
Change-Id: Id94831651c3266861435272a6e36c7884bef2c45 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'libs/nanopb/tests/regression/issue_205')
-rw-r--r--libs/nanopb/tests/regression/issue_205/SConscript14
-rw-r--r--libs/nanopb/tests/regression/issue_205/size_corruption.c12
-rw-r--r--libs/nanopb/tests/regression/issue_205/size_corruption.proto11
3 files changed, 37 insertions, 0 deletions
diff --git a/libs/nanopb/tests/regression/issue_205/SConscript b/libs/nanopb/tests/regression/issue_205/SConscript
new file mode 100644
index 00000000..ed8899dd
--- /dev/null
+++ b/libs/nanopb/tests/regression/issue_205/SConscript
@@ -0,0 +1,14 @@
+# Check that pb_release() correctly handles corrupted size fields of
+# static arrays.
+
+Import('env', 'malloc_env')
+
+env.NanopbProto('size_corruption')
+
+p = malloc_env.Program(["size_corruption.c",
+ "size_corruption.pb.c",
+ "$COMMON/pb_decode_with_malloc.o",
+ "$COMMON/pb_common_with_malloc.o",
+ "$COMMON/malloc_wrappers.o"])
+env.RunTest(p)
+
diff --git a/libs/nanopb/tests/regression/issue_205/size_corruption.c b/libs/nanopb/tests/regression/issue_205/size_corruption.c
new file mode 100644
index 00000000..08cef457
--- /dev/null
+++ b/libs/nanopb/tests/regression/issue_205/size_corruption.c
@@ -0,0 +1,12 @@
+#include "size_corruption.pb.h"
+#include <pb_decode.h>
+
+int main()
+{
+ MainMessage msg = MainMessage_init_zero;
+ msg.bar_count = (pb_size_t)-1;
+ pb_release(MainMessage_fields, &msg);
+
+ return 0;
+}
+
diff --git a/libs/nanopb/tests/regression/issue_205/size_corruption.proto b/libs/nanopb/tests/regression/issue_205/size_corruption.proto
new file mode 100644
index 00000000..6c9c2453
--- /dev/null
+++ b/libs/nanopb/tests/regression/issue_205/size_corruption.proto
@@ -0,0 +1,11 @@
+syntax = "proto2";
+import 'nanopb.proto';
+
+message SubMessage {
+ repeated int32 foo = 1 [(nanopb).type = FT_POINTER];
+}
+
+message MainMessage {
+ repeated SubMessage bar = 1 [(nanopb).max_count = 5];
+}
+