mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
refactor(intro): avoid Coverity warning (#22000)
refactor(intro): avoid coverity warning Problem: Coverity warns about overwriting "mesg" leaking memory. Solution: Make it clear that "mesg" will not be overwritten.
This commit is contained in:
@@ -2785,13 +2785,6 @@ void maybe_intro_message(void)
|
|||||||
/// @param colon true for ":intro"
|
/// @param colon true for ":intro"
|
||||||
void intro_message(int colon)
|
void intro_message(int colon)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
long row;
|
|
||||||
long blanklines;
|
|
||||||
int sponsor;
|
|
||||||
char *p;
|
|
||||||
char *mesg;
|
|
||||||
int mesg_size;
|
|
||||||
static char *(lines[]) = {
|
static char *(lines[]) = {
|
||||||
N_(NVIM_VERSION_LONG),
|
N_(NVIM_VERSION_LONG),
|
||||||
"",
|
"",
|
||||||
@@ -2813,7 +2806,7 @@ void intro_message(int colon)
|
|||||||
size_t lines_size = ARRAY_SIZE(lines);
|
size_t lines_size = ARRAY_SIZE(lines);
|
||||||
assert(lines_size <= LONG_MAX);
|
assert(lines_size <= LONG_MAX);
|
||||||
|
|
||||||
blanklines = Rows - ((long)lines_size - 1L);
|
long blanklines = Rows - ((long)lines_size - 1L);
|
||||||
|
|
||||||
// Don't overwrite a statusline. Depends on 'cmdheight'.
|
// Don't overwrite a statusline. Depends on 'cmdheight'.
|
||||||
if (p_ls > 1) {
|
if (p_ls > 1) {
|
||||||
@@ -2826,17 +2819,17 @@ void intro_message(int colon)
|
|||||||
|
|
||||||
// Show the sponsor and register message one out of four times, the Uganda
|
// Show the sponsor and register message one out of four times, the Uganda
|
||||||
// message two out of four times.
|
// message two out of four times.
|
||||||
sponsor = (int)time(NULL);
|
int sponsor = (int)time(NULL);
|
||||||
sponsor = ((sponsor & 2) == 0) - ((sponsor & 4) == 0);
|
sponsor = ((sponsor & 2) == 0) - ((sponsor & 4) == 0);
|
||||||
|
|
||||||
// start displaying the message lines after half of the blank lines
|
// start displaying the message lines after half of the blank lines
|
||||||
row = blanklines / 2;
|
long row = blanklines / 2;
|
||||||
|
|
||||||
if (((row >= 2) && (Columns >= 50)) || colon) {
|
if (((row >= 2) && (Columns >= 50)) || colon) {
|
||||||
for (i = 0; i < (int)ARRAY_SIZE(lines); i++) {
|
for (int i = 0; i < (int)ARRAY_SIZE(lines); i++) {
|
||||||
p = lines[i];
|
char *p = lines[i];
|
||||||
mesg = NULL;
|
char *mesg = NULL;
|
||||||
mesg_size = 0;
|
int mesg_size = 0;
|
||||||
|
|
||||||
if (strstr(p, "news") != NULL) {
|
if (strstr(p, "news") != NULL) {
|
||||||
p = _(p);
|
p = _(p);
|
||||||
@@ -2846,18 +2839,15 @@ void intro_message(int colon)
|
|||||||
mesg = xmallocz((size_t)mesg_size);
|
mesg = xmallocz((size_t)mesg_size);
|
||||||
snprintf(mesg, (size_t)mesg_size + 1, p,
|
snprintf(mesg, (size_t)mesg_size + 1, p,
|
||||||
STR(NVIM_VERSION_MAJOR), STR(NVIM_VERSION_MINOR));
|
STR(NVIM_VERSION_MAJOR), STR(NVIM_VERSION_MINOR));
|
||||||
}
|
} else if (sponsor != 0) {
|
||||||
|
|
||||||
if (sponsor != 0) {
|
|
||||||
if (strstr(p, "children") != NULL) {
|
if (strstr(p, "children") != NULL) {
|
||||||
mesg = sponsor < 0
|
p = sponsor < 0
|
||||||
? _("Sponsor Vim development!")
|
? N_("Sponsor Vim development!")
|
||||||
: _("Become a registered Vim user!");
|
: N_("Become a registered Vim user!");
|
||||||
}
|
} else if (strstr(p, "iccf") != NULL) {
|
||||||
if (strstr(p, "iccf") != NULL) {
|
p = sponsor < 0
|
||||||
mesg = sponsor < 0
|
? N_("type :help sponsor<Enter> for information ")
|
||||||
? _("type :help sponsor<Enter> for information ")
|
: N_("type :help register<Enter> for information ");
|
||||||
: _("type :help register<Enter> for information ");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user