aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/ext/census/resource.c
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-04-13 20:28:53 -0700
committerGravatar GitHub <noreply@github.com>2017-04-13 20:28:53 -0700
commita6ede891206521ab0c5ad238584bec68a5b2c53a (patch)
tree7ba070589e36e227c2873aad63d81d628a2d8421 /src/core/ext/census/resource.c
parentde8dba47f6411d1fcd8fe58e46d21a18196700fe (diff)
parent0362d6b374e4b10e324e09e750b88d6c6bc834d1 (diff)
Merge pull request #10630 from ctiller/ubsan
ubsan fixes
Diffstat (limited to 'src/core/ext/census/resource.c')
-rw-r--r--src/core/ext/census/resource.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/core/ext/census/resource.c b/src/core/ext/census/resource.c
index ed44f004f9..26ea1a8672 100644
--- a/src/core/ext/census/resource.c
+++ b/src/core/ext/census/resource.c
@@ -223,7 +223,9 @@ size_t allocate_resource(void) {
if (n_resources == n_defined_resources) {
size_t new_n_resources = n_resources ? n_resources * 2 : 2;
resource **new_resources = gpr_malloc(new_n_resources * sizeof(resource *));
- memcpy(new_resources, resources, n_resources * sizeof(resource *));
+ if (n_resources != 0) {
+ memcpy(new_resources, resources, n_resources * sizeof(resource *));
+ }
memset(new_resources + n_resources, 0,
(new_n_resources - n_resources) * sizeof(resource *));
gpr_free(resources);