File tree 2 files changed +7
-0
lines changed
2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change 35
35
#include < iosfwd>
36
36
#include < algorithm>
37
37
#include " macros.h"
38
+ #include " exceptions.h"
38
39
39
40
namespace cppkafka {
40
41
@@ -75,6 +76,9 @@ class CPPKAFKA_API Buffer {
75
76
Buffer (const T* data, size_t size)
76
77
: data_(reinterpret_cast <const DataType*>(data)), size_(size) {
77
78
static_assert (sizeof (T) == sizeof (DataType), " sizeof(T) != sizeof(DataType)" );
79
+ if ((data_ == nullptr ) && (size_ > 0 )) {
80
+ throw Exception (" Invalid buffer configuration" );
81
+ }
78
82
}
79
83
80
84
/* *
Original file line number Diff line number Diff line change @@ -15,6 +15,9 @@ TEST_CASE("conversions", "[buffer]") {
15
15
const Buffer buffer (data);
16
16
const Buffer empty_buffer;
17
17
18
+ SECTION (" construction" ) {
19
+ CHECK_THROWS_AS (Buffer ((const char *)nullptr , 5 ), Exception);
20
+ }
18
21
19
22
SECTION (" bool conversion" ) {
20
23
CHECK (!!buffer == true );
You can’t perform that action at this time.
0 commit comments