Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Kate
Commits
52faa15f
Commit
52faa15f
authored
Dec 21, 2013
by
Dominik Haumann
Browse files
fix crashes in KateDocument::defStyleNum() by adding if-guards.
BUG: 328271
REVIEW: 114586 FIXED-IN: 4.12.1
parent
ceb706f7
Changes
1
Hide whitespace changes
Inline
Side-by-side
part/document/katedocument.cpp
View file @
52faa15f
...
...
@@ -5465,34 +5465,41 @@ Kate::SwapFile* KateDocument::swapFile()
int
KateDocument
::
defStyleNum
(
int
line
,
int
column
)
{
// Validate parameters to prevent out of range access
if
(
0
<=
line
&&
line
<
lines
()
&&
0
<=
column
)
{
QList
<
KTextEditor
::
Attribute
::
Ptr
>
attributes
=
highlight
()
->
attributes
(
static_cast
<
KateView
*>
(
activeView
())
->
renderer
()
->
config
()
->
schema
()
);
// get highlighted line
Kate
::
TextLine
tl
=
kateTextLine
(
line
);
/**
* either get char attribute or attribute of context still active at end of line
*/
int
attribute
=
0
;
if
(
column
<
tl
->
length
())
attribute
=
tl
->
attribute
(
column
);
else
if
(
column
==
tl
->
length
())
{
KateHlContext
*
context
=
tl
->
contextStack
().
isEmpty
()
?
highlight
()
->
contextNum
(
0
)
:
highlight
()
->
contextNum
(
tl
->
contextStack
().
back
());
attribute
=
context
->
attr
;
}
else
return
-
1
;
KTextEditor
::
Attribute
::
Ptr
a
=
attributes
[
attribute
];
return
a
->
property
(
KateExtendedAttribute
::
AttributeDefaultStyleIndex
).
toInt
();
}
return
-
1
;
if
(
line
<
0
||
line
>=
lines
()
||
column
<
0
)
return
-
1
;
// get highlighted line
Kate
::
TextLine
tl
=
kateTextLine
(
line
);
// make sure the textline is a valid pointer
if
(
!
tl
)
return
-
1
;
/**
* either get char attribute or attribute of context still active at end of line
*/
int
attribute
=
0
;
if
(
column
<
tl
->
length
())
attribute
=
tl
->
attribute
(
column
);
else
if
(
column
==
tl
->
length
())
{
KateHlContext
*
context
=
tl
->
contextStack
().
isEmpty
()
?
highlight
()
->
contextNum
(
0
)
:
highlight
()
->
contextNum
(
tl
->
contextStack
().
back
());
attribute
=
context
->
attr
;
}
else
return
-
1
;
QList
<
KTextEditor
::
Attribute
::
Ptr
>
attributes
=
highlight
()
->
attributes
(
static_cast
<
KateView
*>
(
activeView
())
->
renderer
()
->
config
()
->
schema
()
);
// sanity check for the attribute
if
(
attribute
<
0
||
attribute
>=
attributes
.
size
())
return
-
1
;
KTextEditor
::
Attribute
::
Ptr
a
=
attributes
[
attribute
];
return
a
->
property
(
KateExtendedAttribute
::
AttributeDefaultStyleIndex
).
toInt
();
}
bool
KateDocument
::
isComment
(
int
line
,
int
column
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment