diff --git a/php/ext/google/protobuf/php-upb.c b/php/ext/google/protobuf/php-upb.c index b40b76f7f298..7537506adce0 100644 --- a/php/ext/google/protobuf/php-upb.c +++ b/php/ext/google/protobuf/php-upb.c @@ -64,10 +64,10 @@ Error, UINTPTR_MAX is undefined // overall - in that case, it can overlap with the trailing padding of the rest // of the struct, and a naive sizeof(base) + sizeof(flex) * count calculation // will not take into account that overlap, and allocate more than is required. -#define UPB_SIZEOF_FLEX(type, member, count) \ - (UPB_MAX(sizeof(type), \ - (offsetof(type, member) + \ - count * (offsetof(type, member[1]) - offsetof(type, member[0]))))) +#define UPB_SIZEOF_FLEX(type, member, count) \ + (UPB_MAX(sizeof(type), \ + (offsetof(type, member) + (count) * (offsetof(type, member[1]) - \ + offsetof(type, member[0]))))) #define UPB_MAPTYPE_STRING 0 diff --git a/php/ext/google/protobuf/php-upb.h b/php/ext/google/protobuf/php-upb.h index b0874336f1cd..0110e6a20cf4 100644 --- a/php/ext/google/protobuf/php-upb.h +++ b/php/ext/google/protobuf/php-upb.h @@ -63,10 +63,10 @@ Error, UINTPTR_MAX is undefined // overall - in that case, it can overlap with the trailing padding of the rest // of the struct, and a naive sizeof(base) + sizeof(flex) * count calculation // will not take into account that overlap, and allocate more than is required. -#define UPB_SIZEOF_FLEX(type, member, count) \ - (UPB_MAX(sizeof(type), \ - (offsetof(type, member) + \ - count * (offsetof(type, member[1]) - offsetof(type, member[0]))))) +#define UPB_SIZEOF_FLEX(type, member, count) \ + (UPB_MAX(sizeof(type), \ + (offsetof(type, member) + (count) * (offsetof(type, member[1]) - \ + offsetof(type, member[0]))))) #define UPB_MAPTYPE_STRING 0 diff --git a/ruby/ext/google/protobuf_c/ruby-upb.c b/ruby/ext/google/protobuf_c/ruby-upb.c index 266b14e93800..9fd889fc6f58 100644 --- a/ruby/ext/google/protobuf_c/ruby-upb.c +++ b/ruby/ext/google/protobuf_c/ruby-upb.c @@ -64,10 +64,10 @@ Error, UINTPTR_MAX is undefined // overall - in that case, it can overlap with the trailing padding of the rest // of the struct, and a naive sizeof(base) + sizeof(flex) * count calculation // will not take into account that overlap, and allocate more than is required. -#define UPB_SIZEOF_FLEX(type, member, count) \ - (UPB_MAX(sizeof(type), \ - (offsetof(type, member) + \ - count * (offsetof(type, member[1]) - offsetof(type, member[0]))))) +#define UPB_SIZEOF_FLEX(type, member, count) \ + (UPB_MAX(sizeof(type), \ + (offsetof(type, member) + (count) * (offsetof(type, member[1]) - \ + offsetof(type, member[0]))))) #define UPB_MAPTYPE_STRING 0 diff --git a/ruby/ext/google/protobuf_c/ruby-upb.h b/ruby/ext/google/protobuf_c/ruby-upb.h index 6593d47f7a2b..3c3dd7093873 100755 --- a/ruby/ext/google/protobuf_c/ruby-upb.h +++ b/ruby/ext/google/protobuf_c/ruby-upb.h @@ -65,10 +65,10 @@ Error, UINTPTR_MAX is undefined // overall - in that case, it can overlap with the trailing padding of the rest // of the struct, and a naive sizeof(base) + sizeof(flex) * count calculation // will not take into account that overlap, and allocate more than is required. -#define UPB_SIZEOF_FLEX(type, member, count) \ - (UPB_MAX(sizeof(type), \ - (offsetof(type, member) + \ - count * (offsetof(type, member[1]) - offsetof(type, member[0]))))) +#define UPB_SIZEOF_FLEX(type, member, count) \ + (UPB_MAX(sizeof(type), \ + (offsetof(type, member) + (count) * (offsetof(type, member[1]) - \ + offsetof(type, member[0]))))) #define UPB_MAPTYPE_STRING 0