Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
57eb9f00
Commit
57eb9f00
authored
Nov 27, 2004
by
serg@serg.mylan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better overflow checks in decimal2ulonglong
better truncation check in decimal2ulonglong
parent
7dabb641
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
strings/decimal.c
strings/decimal.c
+7
-3
No files found.
strings/decimal.c
View file @
57eb9f00
...
@@ -503,7 +503,7 @@ int decimal2ulonglong(decimal *from, ulonglong *to)
...
@@ -503,7 +503,7 @@ int decimal2ulonglong(decimal *from, ulonglong *to)
{
{
dec1
*
buf
=
from
->
buf
;
dec1
*
buf
=
from
->
buf
;
ulonglong
x
=
0
;
ulonglong
x
=
0
;
int
intg
;
int
intg
,
frac
;
if
(
from
->
sign
)
if
(
from
->
sign
)
{
{
...
@@ -515,14 +515,17 @@ int decimal2ulonglong(decimal *from, ulonglong *to)
...
@@ -515,14 +515,17 @@ int decimal2ulonglong(decimal *from, ulonglong *to)
{
{
ulonglong
y
=
x
;
ulonglong
y
=
x
;
x
=
x
*
DIG_BASE
+
*
buf
++
;
x
=
x
*
DIG_BASE
+
*
buf
++
;
if
(
unlikely
(
x
<
y
))
if
(
unlikely
(
y
>
(
ULONGLONG_MAX
/
DIG_BASE
)
||
x
<
y
))
{
{
*
to
=
y
;
*
to
=
y
;
return
E_DEC_OVERFLOW
;
return
E_DEC_OVERFLOW
;
}
}
}
}
*
to
=
x
;
*
to
=
x
;
return
from
->
frac
?
E_DEC_TRUNCATED
:
E_DEC_OK
;
for
(
frac
=
from
->
frac
;
unlikely
(
frac
>
0
);
frac
-=
DIG_PER_DEC1
)
if
(
*
buf
++
)
return
E_DEC_TRUNCATED
;
return
E_DEC_OK
;
}
}
int
decimal2longlong
(
decimal
*
from
,
longlong
*
to
)
int
decimal2longlong
(
decimal
*
from
,
longlong
*
to
)
...
@@ -1928,6 +1931,7 @@ main()
...
@@ -1928,6 +1931,7 @@ main()
test_d2ull
(
"18446744073709551616"
);
test_d2ull
(
"18446744073709551616"
);
test_d2ull
(
"-1"
);
test_d2ull
(
"-1"
);
test_d2ull
(
"1.23"
);
test_d2ull
(
"1.23"
);
test_d2ull
(
"9999999999999999999999999.000"
);
printf
(
"==== longlong2decimal ====
\n
"
);
printf
(
"==== longlong2decimal ====
\n
"
);
test_ll2d
(
LL
(
-
12345
));
test_ll2d
(
LL
(
-
12345
));
...
...
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