Hi Jia Yeou, As far as I know, the memory allocated by realloc here should be initialized on caller(s) of addrvec_grow - if you check the call graph of addrvec_grow you will see where the memory gets initialized. Basically the memory will only be initialized when we know what to fill in; rather than zero the chunk out with memset immediately after realloc, we save a sys call by lazy initializing.
If you could provide more information (such as a call stack) that pointed out the uninitialized memory cause any issue that would be helpful. Also, for bug report, please directly open an issue at https://issues.apache.org/jira/browse/ZOOKEEPER. On Sat, Jan 21, 2017 at 10:47 AM, Jia Yeou Yeh <[email protected]> wrote: > version: 3.5.2-alpha > function: c client library > file:addrvec.c > function: addrvec_grow > > bug source: after c function "realloc" call , the new buffer without > initialized ,after that when then function "addrvec_contains" by means of > memcmp will always evaluate to false ; > action: add memset(avec->data,'\0',sizeof(*avec->data)*avec->capacity); > after success realloc. > -- > 大州數位服務股份有限公司 > 葉佳友 > 台北市杭州南路一段27號9樓 > 電話:(02)2394-8686 > 傳真:(02)2394-2929 > 手機:0939112959 > E-Mail:[email protected] > > -- Cheers Michael.
