From: Rafal Somla Date: September 10 2010 11:57am Subject: Re: bzr commit into mysql-5.5 branch (Georgi.Kodinov:3082) WL#5366 List-Archive: http://lists.mysql.com/commits/117998 Message-Id: <4C8A1D31.7090100@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hello Joro, I think I spot another problem with your code. I discovered it when I tried to use similar trick in my own code... Georgi Kodinov wrote: > #At file:///home/kgeorge/mysql/work/wl5366-5.5/ based on revid:georgi.kodinov@stripped ... > + > + do > + { > + rc= getpwnam_r(name, pwd_arg, buf, buf_size, &ret); > + > + if (rc == ERANGE) > + { > + /* > + The buffer specified by the buffer and bufsize argu- > + ments was insufficiently sized to store the result. > + The caller should retry with a larger buffer. > + */ > + buf= (char *) ((*to_free) ? > + realloc(*to_free, buf_size * 2) : > + malloc(buf_size * 2)); > + > + if (!buf) > + { > + free(*to_free); > + *to_free= NULL; > + return NULL; > + } > + > + *to_free= buf; > + buf_size*= 2; > + continue; I think the intention here is that the loop will repeat, so that a call to getpwnam_r() with a bigger buffer will be made again. But continue will move to the end of the loop and terminate it, since condition is always false... > + } > + } while (0); > + > + if (rc) > + { > + free(to_free); > + *to_free= NULL; > + return NULL; > + } > + > + return ret; > +#else > + return NULL; > +#endif > +} Rafal