30
30
// *****************************************************************************
31
31
bool ws_pb_decode (pb_istream_t *stream, const pb_msgdesc_t *fields,
32
32
void *dest_struct) {
33
+ if (!stream || !fields || !dest_struct) {
34
+ WS_DEBUG_PRINTLN (" Protobuf decode error: Invalid arguments to function" );
35
+ if (!stream) {
36
+ WS_DEBUG_PRINTLN (" stream is NULL" );
37
+ } else if (stream == nullptr ) {
38
+ WS_DEBUG_PRINTLN (" stream is nullptr" );
39
+ }
40
+
41
+ if (!fields) {
42
+ WS_DEBUG_PRINTLN (" fields is NULL" );
43
+ } else if (fields == nullptr ) {
44
+ WS_DEBUG_PRINTLN (" fields is nullptr" );
45
+ }
46
+
47
+ if (!dest_struct) {
48
+ WS_DEBUG_PRINTLN (" dest_struct is NULL" );
49
+ } else if (dest_struct == nullptr ) {
50
+ WS_DEBUG_PRINTLN (" dest_struct is nullptr" );
51
+ }
52
+ return false ;
53
+ }
33
54
bool status = pb_decode (stream, fields, dest_struct);
34
55
if (!status) {
35
56
WS_DEBUG_PRINT (" Protobuf decode error: " );
@@ -52,6 +73,27 @@ bool ws_pb_decode(pb_istream_t *stream, const pb_msgdesc_t *fields,
52
73
// *****************************************************************************
53
74
bool ws_pb_encode (pb_ostream_t *stream, const pb_msgdesc_t *fields,
54
75
const void *src_struct) {
76
+ if (!stream || !fields || !src_struct) {
77
+ WS_DEBUG_PRINTLN (" Protobuf encode error: Invalid arguments to function" );
78
+ if (!stream) {
79
+ WS_DEBUG_PRINTLN (" stream is NULL" );
80
+ } else if (stream == nullptr ) {
81
+ WS_DEBUG_PRINTLN (" stream is nullptr" );
82
+ }
83
+
84
+ if (!fields) {
85
+ WS_DEBUG_PRINTLN (" fields is NULL" );
86
+ } else if (fields == nullptr ) {
87
+ WS_DEBUG_PRINTLN (" fields is nullptr" );
88
+ }
89
+
90
+ if (!src_struct) {
91
+ WS_DEBUG_PRINTLN (" src_struct is NULL" );
92
+ } else if (src_struct == nullptr ) {
93
+ WS_DEBUG_PRINTLN (" src_struct is nullptr" );
94
+ }
95
+ return false ;
96
+ }
55
97
bool status = pb_encode (stream, fields, src_struct);
56
98
if (!status) {
57
99
WS_DEBUG_PRINT (" Protobuf encode error: " );
0 commit comments