3030// *****************************************************************************
3131bool ws_pb_decode (pb_istream_t *stream, const pb_msgdesc_t *fields,
3232 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+ }
3354 bool status = pb_decode (stream, fields, dest_struct);
3455 if (!status) {
3556 WS_DEBUG_PRINT (" Protobuf decode error: " );
@@ -52,6 +73,27 @@ bool ws_pb_decode(pb_istream_t *stream, const pb_msgdesc_t *fields,
5273// *****************************************************************************
5374bool ws_pb_encode (pb_ostream_t *stream, const pb_msgdesc_t *fields,
5475 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+ }
5597 bool status = pb_encode (stream, fields, src_struct);
5698 if (!status) {
5799 WS_DEBUG_PRINT (" Protobuf encode error: " );
0 commit comments