@@ -551,33 +551,41 @@ static inline int msgpack_pack_ext(msgpack_packer* x, char typecode, size_t l)
551551 */
552552static inline int msgpack_pack_timestamp (msgpack_packer * x , int64_t seconds , uint32_t nanoseconds )
553553{
554+ int ret ;
554555 if ((seconds >> 34 ) == 0 ) {
555556 /* seconds is unsigned and fits in 34 bits */
556557 uint64_t data64 = ((uint64_t )nanoseconds << 34 ) | (uint64_t )seconds ;
557558 if ((data64 & 0xffffffff00000000L ) == 0 ) {
558559 /* no nanoseconds and seconds is 32bits or smaller. timestamp32. */
559560 unsigned char buf [4 ];
560561 uint32_t data32 = (uint32_t )data64 ;
561- msgpack_pack_ext (x , -1 , 4 );
562+ ret = msgpack_pack_ext (x , -1 , 4 );
563+ if (ret != 0 )
564+ return ret ;
565+
562566 _msgpack_store32 (buf , data32 );
563- msgpack_pack_raw_body (x , buf , 4 );
567+ return msgpack_pack_raw_body (x , buf , 4 );
564568 } else {
565569 /* timestamp64 */
566570 unsigned char buf [8 ];
567- msgpack_pack_ext (x , -1 , 8 );
568- _msgpack_store64 ( buf , data64 );
569- msgpack_pack_raw_body ( x , buf , 8 ) ;
571+ ret = msgpack_pack_ext (x , -1 , 8 );
572+ if ( ret != 0 )
573+ return ret ;
570574
575+ _msgpack_store64 (buf , data64 );
576+ return msgpack_pack_raw_body (x , buf , 8 );
571577 }
572578 } else {
573- /* seconds is signed or >34bits */
574- unsigned char buf [12 ];
575- _msgpack_store32 (& buf [0 ], nanoseconds );
576- _msgpack_store64 (& buf [4 ], seconds );
577- msgpack_pack_ext (x , -1 , 12 );
578- msgpack_pack_raw_body (x , buf , 12 );
579+ /* seconds is signed or >34bits */
580+ unsigned char buf [12 ];
581+ _msgpack_store32 (& buf [0 ], nanoseconds );
582+ _msgpack_store64 (& buf [4 ], seconds );
583+ ret = msgpack_pack_ext (x , -1 , 12 );
584+ if (ret != 0 )
585+ return ret ;
586+
587+ return msgpack_pack_raw_body (x , buf , 12 );
579588 }
580- return 0 ;
581589}
582590
583591
0 commit comments