Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Zwinkau
libfirm
Commits
621e1ef4
Commit
621e1ef4
authored
Jun 01, 2015
by
yb9976
Browse files
Fixed off-by-one error during parsing of asm constraints.
This fixes some errors reported by memcheck.
parent
91566fc2
Changes
1
Hide whitespace changes
Inline
Side-by-side
ir/be/beasm.c
View file @
621e1ef4
...
@@ -76,8 +76,7 @@ void be_parse_asm_constraints_internal(be_asm_constraint_t *const constraint, id
...
@@ -76,8 +76,7 @@ void be_parse_asm_constraints_internal(be_asm_constraint_t *const constraint, id
bool
all_registers_allowed
=
false
;
bool
all_registers_allowed
=
false
;
int
same_as
=
-
1
;
int
same_as
=
-
1
;
while
(
*
i
!=
'\0'
)
{
while
(
*
i
!=
'\0'
)
{
char
const
l
=
*
i
++
;
switch
(
*
i
)
{
switch
(
l
)
{
/* Skip spaces, out/in-out marker. */
/* Skip spaces, out/in-out marker. */
case
' '
:
case
' '
:
case
'\t'
:
case
'\t'
:
...
@@ -86,26 +85,28 @@ void be_parse_asm_constraints_internal(be_asm_constraint_t *const constraint, id
...
@@ -86,26 +85,28 @@ void be_parse_asm_constraints_internal(be_asm_constraint_t *const constraint, id
case
'+'
:
case
'+'
:
case
'&'
:
case
'&'
:
case
'*'
:
case
'*'
:
++
i
;
break
;
break
;
case
'#'
:
case
'#'
:
while
(
*
i
!=
'\0'
&&
*
i
!=
','
)
do
{
++
i
;
++
i
;
}
while
(
*
i
!=
'\0'
&&
*
i
!=
','
);
break
;
break
;
default:
default:
if
(
is_digit
(
l
))
{
if
(
is_digit
(
*
i
))
{
if
(
is_output
)
if
(
is_output
)
panic
(
"can only specify same constraint on input"
);
panic
(
"can only specify same constraint on input"
);
int
p
;
int
p
;
sscanf
(
i
-
1
,
"%d%n"
,
&
same_as
,
&
p
);
sscanf
(
i
,
"%d%n"
,
&
same_as
,
&
p
);
if
(
same_as
>=
0
)
if
(
same_as
>=
0
)
i
+=
p
;
i
+=
p
;
}
else
{
}
else
{
be_asm_constraint_t
new_constraint
;
be_asm_constraint_t
new_constraint
;
memset
(
&
new_constraint
,
0
,
sizeof
(
new_constraint
));
memset
(
&
new_constraint
,
0
,
sizeof
(
new_constraint
));
parse_constraint_letter
(
env
,
&
new_constraint
,
l
);
parse_constraint_letter
(
env
,
&
new_constraint
,
*
i
++
);
limited
|=
new_constraint
.
allowed_registers
;
limited
|=
new_constraint
.
allowed_registers
;
all_registers_allowed
|=
new_constraint
.
all_registers_allowed
;
all_registers_allowed
|=
new_constraint
.
all_registers_allowed
;
...
...
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