Alexey Tourbin <[EMAIL PROTECTED]> writes:
> va_start(params, fmt);
> - vasprintf((char **) &buf, fmt, params);
> + rv = vasprintf((char **) &buf, fmt, params);
> + if (rv < 0) {
> + perror("vasprintf");
> + return;
> + }
> va_end(params);
> elinks_internal("assertion failed: %s", buf);
This is wrong. va_end and elinks_internal must be called even if
vasprintf fails.
Possibilities to be handled:
(a) vasprintf returns an error and doesn't alter buf. Because
buf is initialized as NULL, this is the same as (b).
(b) vasprintf returns an error and sets buf = NULL. This NULL
should not be passed to elinks_internal because it will go
to snprintf from there and perhaps cause a crash. The NULL
could be replaced with an empty string. Displaying the
error from vasprintf may be useful but may also distract
users into reporting that error instead of the file name and
line number.
(c) vasprintf returns an error but sets buf != NULL. In this
case the string probably contains something sensible so it
should be used.
(d) vasprintf returns success but sets buf = NULL. That should
not be possible.
(e) vasprintf returns success and sets buf != NULL. This is the
usual case.
pgpkC0sNPSKBx.pgp
Description: PGP signature
_______________________________________________ elinks-dev mailing list [email protected] http://linuxfromscratch.org/mailman/listinfo/elinks-dev
