aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2022-04-15 19:53:45 +0200
committerSven Gothel <[email protected]>2022-04-15 19:53:45 +0200
commite4d108f0e4cfad10c2c00283f4686145859069f8 (patch)
treefb895a4395a827113514a5c0da15f2c39b82a27d /examples
parenta85d533da5ba7228d8d0f388540d719e40f92de0 (diff)
Zero uninitialized POctet values (valgrind: conditional jump)
Diffstat (limited to 'examples')
-rw-r--r--examples/dbt_peripheral00.cpp5
-rw-r--r--examples/java/DBTPeripheral00.java1
2 files changed, 5 insertions, 1 deletions
diff --git a/examples/dbt_peripheral00.cpp b/examples/dbt_peripheral00.cpp
index e214ce37..99cb04f8 100644
--- a/examples/dbt_peripheral00.cpp
+++ b/examples/dbt_peripheral00.cpp
@@ -107,6 +107,7 @@ static jau::POctets make_poctets(const char* name) {
static jau::POctets make_poctets(const char* name, const jau::nsize_t capacity) {
const nsize_t name_len = (nsize_t)strlen(name);
jau::POctets p( std::max<nsize_t>(capacity, name_len), name_len, endian::little );
+ p.bzero();
p.put_bytes_nc(0, reinterpret_cast<const uint8_t*>(name), name_len);
return p;
}
@@ -116,7 +117,9 @@ static jau::POctets make_poctets(const uint16_t v) {
return p;
}
static jau::POctets make_poctets(const jau::nsize_t capacity, const jau::nsize_t size) {
- return jau::POctets(capacity, size, endian::little);
+ jau::POctets p(capacity, size, endian::little);
+ p.bzero();
+ return p;
}
static const jau::uuid128_t DataServiceUUID = jau::uuid128_t("d0ca6bf3-3d50-4760-98e5-fc5883e93712");
diff --git a/examples/java/DBTPeripheral00.java b/examples/java/DBTPeripheral00.java
index 567305c7..5e077c6c 100644
--- a/examples/java/DBTPeripheral00.java
+++ b/examples/java/DBTPeripheral00.java
@@ -154,6 +154,7 @@ public class DBTPeripheral00 {
}
static DBGattValue make_gvalue(final int capacity, final int size) {
final byte[] p = new byte[size];
+ Arrays.fill(p, (byte)0);
return new DBGattValue(p, capacity, true /* variable_length */);
}