summaryrefslogtreecommitdiff
path: root/upb/encode.c
diff options
context:
space:
mode:
authorJoshua Haberman <jhaberman@gmail.com>2017-07-18 11:48:29 +0200
committerJoshua Haberman <jhaberman@gmail.com>2017-07-18 11:48:29 +0200
commit806ffc1d2053f1c02167c7965b39abc997d12ad6 (patch)
tree3f0943a888e0f164997c344c1763ef82a619844b /upb/encode.c
parent15308afff2d0d288b73c1b4278bd28f926ce02b8 (diff)
Responded to PR comments.
Diffstat (limited to 'upb/encode.c')
-rw-r--r--upb/encode.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/upb/encode.c b/upb/encode.c
index 4aafb9c..e7585eb 100644
--- a/upb/encode.c
+++ b/upb/encode.c
@@ -32,7 +32,7 @@ static const uint8_t upb_desctype_to_fieldtype[] = {
static size_t upb_encode_varint(uint64_t val, char *buf) {
size_t i;
- if (val == 0) { buf[0] = 0; return 1; }
+ if (val < 128) { buf[0] = val; return 1; }
i = 0;
while (val) {
uint8_t byte = val & 0x7fU;
@@ -373,7 +373,11 @@ char *upb_encode(const void *msg, const upb_msglayout_msginit_v1 *m,
e.limit = NULL;
e.ptr = NULL;
- CHK(upb_encode_message(&e, msg, m, size));
+ if (!upb_encode_message(&e, msg, m, size)) {
+ *size = 0;
+ return NULL;
+ }
+
*size = e.limit - e.ptr;
if (*size == 0) {
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback