diff --git a/lcl/interfaces/gtk/gtkwinapi.inc b/lcl/interfaces/gtk/gtkwinapi.inc index e7744bdad3..9411cb9a36 100644 --- a/lcl/interfaces/gtk/gtkwinapi.inc +++ b/lcl/interfaces/gtk/gtkwinapi.inc @@ -3109,9 +3109,13 @@ var begin AStr := Copy(String(theLine), 1, LineLength); - if (Flags and DT_NoPrefix) <> DT_NoPrefix then - pIndex := DeleteAmpersands(aStr) - else + if (Flags and DT_NoPrefix) <> DT_NoPrefix then begin + pIndex := DeleteAmpersands(aStr); + If Length(aStr) = 0 then + Exit; { String consists of '&' only } + If pIndex > Length(aStr) then + pIndex := -1; { String ended in '&', which was deleted } + end else pIndex := -1; if TempBrush = HBRUSH(-1) then