nanogui@linuxhacker.org
nanogui@linuxhacker.org
Hi all,
I noticed this in `ntextfield.c'. Is this a bug ?
static void textfield_settext (NTEXTFIELD * this, const char * text)
{
int maxsize;
if (text && strlen(text) > 256) maxsize = strlen(text) + 1;
else maxsize = 256;
if (this->maxsize < maxsize) {
if (this->textbuf) free(this->textbuf);
if (this->textbuf = malloc(maxsize)) {
this->textbuf[0] = '\0';
this->maxsize = maxsize;
} else this->maxsize = 0;
}
if (!this->textbuf) free(this->textbuf); <<<< !!!!
if (text) this->textbuf = strdup(text);
else this->textbuf = 0;
if (text && this->textbuf) strcpy(this->textbuf,text);
this->curpos = 0;
this->firstpos = 0;
n_widget_repaint(this);
}
I fail to follow what this section of code does :
if (!this->textbuf) free(this->textbuf);
if (text) this->textbuf = strdup(text);
else this->textbuf = 0;
--
Chris Johns, mailto:ccj@acm.org
nanogui@linuxhacker.org