On Saturday, June 3, 2017 11:11:39 AM PDT Thomas Helland wrote: [snip] > @@ -87,10 +102,18 @@ util_dynarray_trim(struct util_dynarray *buf) > { > if (buf->size != buf->capacity) { > if (buf->size) { > - buf->data = realloc(buf->data, buf->size); > + if (buf->mem_ctx) { > + reralloc_size(buf->mem_ctx, buf->data, buf->size); > + } else { > + buf->data = realloc(buf->data, buf->size); > + }
Hi Thomas, Would it make sense to do: buf->data = reralloc_size(...) It's probably safe as is given that you're trying to trim down an existing allocation to be smaller, but it seems safer to use the return value nonetheless. Coverity grumbled after you pushed the patch: ** CID 1412568: Resource leaks (RESOURCE_LEAK) /src/util/u_dynarray.h: 110 in util_dynarray_trim() ______________________________________________________________ *** CID 1412568: Resource leaks (RESOURCE_LEAK) /src/util/u_dynarray.h: 110 in util_dynarray_trim() 104 static inline void 105 util_dynarray_trim(struct util_dynarray *buf) 106 { 107 if (buf->size != buf->capacity) { 108 if (buf->size) { 109 if (buf->mem_ctx) { >>> CID 1412568: Resource leaks (RESOURCE_LEAK) >>> Ignoring storage allocated by "reralloc_size(buf->mem_ctx, buf->data, >>> buf->size)" leaks it. 110 reralloc_size(buf->mem_ctx, buf->data, buf->size); 111 } else { 112 buf->data = realloc(buf->data, buf->size); 113 } 114 buf->capacity = buf->size; 115 } else {
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev