diff --git a/upb/encode.c b/upb/encode.c index a60d58a96e..ff84275ffb 100644 --- a/upb/encode.c +++ b/upb/encode.c @@ -449,7 +449,7 @@ static bool encode_shouldencode(upb_encstate* e, const upb_Message* msg, return ch != 0; } #if UINTPTR_MAX == 0xffffffff - case upb_FieldRep_Pointer: + case kUpb_FieldRep_Pointer: #endif case kUpb_FieldRep_4Byte: { uint32_t u32; diff --git a/upb/mini_table.c b/upb/mini_table.c index 44fc5c7ff3..e48fb675f2 100644 --- a/upb/mini_table.c +++ b/upb/mini_table.c @@ -561,7 +561,7 @@ static void upb_MtDecoder_Parse(upb_MtDecoder* d, const char* ptr, size_t len, uint32_t last_field_number = 0; bool need_dense_below = d->table != NULL; - d->end = ptr + len; + d->end = UPB_PTRADD(ptr, len); while (ptr < d->end) { char ch = *ptr++; @@ -650,8 +650,10 @@ static bool upb_MtDecoder_SortLayoutItems(upb_MtDecoder* d) { upb_MtDecoder_PushItem(d, item); } - qsort(d->vec.data, d->vec.size, sizeof(*d->vec.data), - upb_MtDecoder_CompareFields); + if (d->vec.size) { + qsort(d->vec.data, d->vec.size, sizeof(*d->vec.data), + upb_MtDecoder_CompareFields); + } return true; } @@ -735,7 +737,7 @@ size_t upb_MtDecoder_Place(upb_MtDecoder* d, upb_FieldRep rep) { } static bool upb_MtDecoder_AssignOffsets(upb_MtDecoder* d) { - upb_LayoutItem* end = d->vec.data + d->vec.size; + upb_LayoutItem* end = UPB_PTRADD(d->vec.data, d->vec.size); // Compute offsets. for (upb_LayoutItem* item = d->vec.data; item < end; item++) {