diff --git a/src/core/ddsc/tests/loan.c b/src/core/ddsc/tests/loan.c index 5e12d84..2b822c7 100644 --- a/src/core/ddsc/tests/loan.c +++ b/src/core/ddsc/tests/loan.c @@ -110,6 +110,7 @@ CU_Test (ddsc_loan, success, .init = create_entities, .fini = delete_entities) CU_ASSERT_FATAL (result == DDS_RETCODE_OK); /* return resets buf[0] (so that it picks up the loan the next time) and zeros the data */ CU_ASSERT_FATAL (ptrs[0] == NULL); + assert (ptr0copy != NULL); /* clang static analyzer */ CU_ASSERT_FATAL (memcmp (ptr0copy, zeros, sizeof (s)) == 0); /* read 3, return: should work fine, causes realloc */ @@ -121,6 +122,7 @@ CU_Test (ddsc_loan, success, .init = create_entities, .fini = delete_entities) result = dds_return_loan (reader, ptrs, n); CU_ASSERT_FATAL (result == DDS_RETCODE_OK); CU_ASSERT_FATAL (ptrs[0] == NULL); + assert (ptr0copy != NULL); /* clang static analyzer */ CU_ASSERT_FATAL (memcmp (ptr0copy, zeros, 3 * sizeof (s)) == 0); /* read 1 using loan, expecting to get the same address (no realloc needed), defer return. @@ -145,6 +147,7 @@ CU_Test (ddsc_loan, success, .init = create_entities, .fini = delete_entities) { const struct RoundTripModule_DataType *a = ptrs[0]; const struct RoundTripModule_DataType *b = ptrs2[0]; + assert (a != NULL && b != NULL); /* clang static analyzer */ CU_ASSERT_FATAL (a->payload._length == b->payload._length); CU_ASSERT_FATAL (a->payload._buffer != b->payload._buffer); CU_ASSERT_FATAL (a->payload._buffer[0] == b->payload._buffer[0]); @@ -164,6 +167,7 @@ CU_Test (ddsc_loan, success, .init = create_entities, .fini = delete_entities) //This should be a use-after-free //CU_ASSERT_FATAL (memcmp (ptr0copy, zeros, sizeof (s)) == 0); + (void) ptr0copy; } CU_Test (ddsc_loan, take_cleanup, .init = create_entities, .fini = delete_entities) diff --git a/src/core/ddsi/src/ddsi_serdata_pserop.c b/src/core/ddsi/src/ddsi_serdata_pserop.c index a3df6d2..1796497 100644 --- a/src/core/ddsi/src/ddsi_serdata_pserop.c +++ b/src/core/ddsi/src/ddsi_serdata_pserop.c @@ -213,6 +213,7 @@ static struct ddsi_serdata *serdata_pserop_from_sample (const struct ddsi_sertop const size_t size4 = (size + 3) & ~(size_t)3; struct ddsi_serdata_pserop *d = serdata_pserop_new (tp, kind, size4, &header); assert (tp->ops_key == NULL || (size >= 16 && tp->memsize >= 16)); + assert (d->data != NULL); // clang static analyzer memcpy (d->data, data, size); memset (d->data + size, 0, size4 - size); d->pos = (uint32_t) size;