mirror of
https://github.com/gryf/wmaker.git
synced 2025-12-19 20:38:08 +01:00
wmaker: do not duplicate a string that does not need to be (Coverity #72814)
As coverity pointed, the duplicated string was never freed. Considering what is done with it, is not necessary to allocate a duplicate for it, it is a waste of time and participates in memory fragmentation. Signed-off-by: Christophe CURIS <christophe.curis@free.fr> Signed-off-by: Carlos R. Mafra <crmafra@gmail.com>
This commit is contained in:
committed by
Carlos R. Mafra
parent
285a926539
commit
877c26b467
12
src/misc.c
12
src/misc.c
@@ -515,9 +515,6 @@ char *ExpandOptions(WScreen *scr, const char *cmdline)
|
|||||||
char *out, *nout;
|
char *out, *nout;
|
||||||
char *selection = NULL;
|
char *selection = NULL;
|
||||||
char *user_input = NULL;
|
char *user_input = NULL;
|
||||||
#ifdef XDND
|
|
||||||
char *dropped_thing = NULL;
|
|
||||||
#endif
|
|
||||||
char tmpbuf[TMPBUFSIZE];
|
char tmpbuf[TMPBUFSIZE];
|
||||||
int slen;
|
int slen;
|
||||||
|
|
||||||
@@ -627,14 +624,11 @@ char *ExpandOptions(WScreen *scr, const char *cmdline)
|
|||||||
|
|
||||||
#ifdef XDND
|
#ifdef XDND
|
||||||
case 'd':
|
case 'd':
|
||||||
if (scr->xdestring) {
|
if (!scr->xdestring) {
|
||||||
dropped_thing = wstrdup(scr->xdestring);
|
|
||||||
}
|
|
||||||
if (!dropped_thing) {
|
|
||||||
scr->flags.dnd_data_convertion_status = 1;
|
scr->flags.dnd_data_convertion_status = 1;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
slen = strlen(dropped_thing);
|
slen = strlen(scr->xdestring);
|
||||||
olen += slen;
|
olen += slen;
|
||||||
nout = realloc(out, olen);
|
nout = realloc(out, olen);
|
||||||
if (!nout) {
|
if (!nout) {
|
||||||
@@ -642,7 +636,7 @@ char *ExpandOptions(WScreen *scr, const char *cmdline)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
out = nout;
|
out = nout;
|
||||||
strcat(out, dropped_thing);
|
strcat(out, scr->xdestring);
|
||||||
optr += slen;
|
optr += slen;
|
||||||
break;
|
break;
|
||||||
#endif /* XDND */
|
#endif /* XDND */
|
||||||
|
|||||||
Reference in New Issue
Block a user