rio: copy window labels for menu3
as the menu is displayed, the window might go away or change its label causing menuhit() to dereference bad memory. just strdup() the labels before passing to menu3str to prevent accidents.
This commit is contained in:
parent
3730a4df53
commit
0a3eb7d6b1
1 changed files with 8 additions and 4 deletions
|
@ -709,10 +709,14 @@ button3menu(void)
|
|||
}
|
||||
if(n >= nelem(menu3str)-Hidden)
|
||||
n = nelem(menu3str)-Hidden-1;
|
||||
for(i=0; i<n; i++)
|
||||
menu3str[i+Hidden] = hidden[i]->label;
|
||||
menu3str[i+Hidden] = nil;
|
||||
|
||||
for(i=0; i<n; i++){
|
||||
free(menu3str[i+Hidden]);
|
||||
menu3str[i+Hidden] = estrdup(hidden[i]->label);
|
||||
}
|
||||
for(i+=Hidden; menu3str[i]; i++){
|
||||
free(menu3str[i]);
|
||||
menu3str[i] = nil;
|
||||
}
|
||||
sweeping = 1;
|
||||
switch(i = menuhit(3, mousectl, &menu3, wscreen)){
|
||||
case -1:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue