Fix pasting going out of bounds and dash the possibility of memory leaks while pasting.
This commit is contained in:
parent
a2faa975cb
commit
ed847e831b
|
@ -10436,14 +10436,16 @@ static void M_HandleConnectIP(INT32 choice)
|
||||||
if (l >= 28-1)
|
if (l >= 28-1)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
const char *paste = I_ClipboardPaste(); // Paste clipboard into char
|
char *paste = (char *)I_ClipboardPaste(); // Paste clipboard into char
|
||||||
|
|
||||||
if ( ctrldown ) {
|
if ( ctrldown ) {
|
||||||
switch (choice) {
|
switch (choice) {
|
||||||
case 118: // ctrl+v, pasting
|
case 118: // ctrl+v, pasting
|
||||||
if (paste != NULL)
|
if (paste != NULL) {
|
||||||
|
if (strlen(paste) + strlen(setupm_ip) >= 28-1)
|
||||||
|
paste[28-1 - strlen(setupm_ip)] = 0;
|
||||||
strcat(setupm_ip, paste); // Concat the ip field with clipboard
|
strcat(setupm_ip, paste); // Concat the ip field with clipboard
|
||||||
setupm_ip[127] = 0; // Truncate to maximum length
|
}
|
||||||
break;
|
break;
|
||||||
case 99: // ctrl+c, copying
|
case 99: // ctrl+c, copying
|
||||||
I_ClipboardCopy(setupm_ip, l);
|
I_ClipboardCopy(setupm_ip, l);
|
||||||
|
|
Loading…
Reference in a new issue