Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
5a7c371e
T
Third Party Harfbuzz
项目概览
OpenHarmony
/
Third Party Harfbuzz
接近 2 年 前同步成功
通知
1
Star
18
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Harfbuzz
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
5a7c371e
编写于
12月 04, 2018
作者:
M
Michiharu Ariza
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
check overflow & clamp
上级
32cc46c7
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
27 addition
and
9 deletion
+27
-9
src/hb-cff-interp-dict-common.hh
src/hb-cff-interp-dict-common.hh
+27
-9
未找到文件。
src/hb-cff-interp-dict-common.hh
浏览文件 @
5a7c371e
...
@@ -105,16 +105,17 @@ struct DictOpSet : OpSet<Number>
...
@@ -105,16 +105,17 @@ struct DictOpSet : OpSet<Number>
static
inline
double
parse_bcd
(
SubByteStr
&
substr
)
static
inline
double
parse_bcd
(
SubByteStr
&
substr
)
{
{
double
v
=
0.0
;
bool
neg
=
false
;
bool
neg
=
false
;
double
int_part
=
0
;
double
int_part
=
0
;
long
frac_part
=
0
;
long
frac_part
=
0
;
unsigned
int
frac_count
=
0
;
unsigned
int
frac_count
=
0
;
bool
exp_neg
=
false
;
bool
exp_neg
=
false
;
unsigned
int
exp_part
=
0
;
unsigned
int
exp_part
=
0
;
bool
exp_overflow
=
false
;
enum
Part
{
INT_PART
=
0
,
FRAC_PART
,
EXP_PART
}
part
=
INT_PART
;
enum
Part
{
INT_PART
=
0
,
FRAC_PART
,
EXP_PART
}
part
=
INT_PART
;
enum
Nibble
{
DECIMAL
=
10
,
EXP_POS
,
EXP_NEG
,
RESERVED
,
NEG
,
END
};
enum
Nibble
{
DECIMAL
=
10
,
EXP_POS
,
EXP_NEG
,
RESERVED
,
NEG
,
END
};
const
unsigned
long
MAX_FRACT
=
0xFFFFFFFFFFFFFlu
;
/* 1^52-1 */
const
unsigned
int
MAX_EXP
=
0x7FFu
;
/* 1^11-1 */
double
value
=
0.0
;
double
value
=
0.0
;
unsigned
char
byte
=
0
;
unsigned
char
byte
=
0
;
...
@@ -139,12 +140,21 @@ struct DictOpSet : OpSet<Number>
...
@@ -139,12 +140,21 @@ struct DictOpSet : OpSet<Number>
{
{
case
RESERVED
:
case
RESERVED
:
substr
.
set_error
();
substr
.
set_error
();
return
v
;
return
v
alue
;
case
END
:
case
END
:
value
=
(
double
)(
neg
?
-
int_part
:
int_part
);
value
=
(
double
)(
neg
?
-
int_part
:
int_part
);
if
(
frac_count
>
0
)
if
(
frac_count
>
0
)
value
+=
(
frac_part
/
pow
(
10.0
,
(
double
)
frac_count
));
value
+=
(
frac_part
/
pow
(
10.0
,
(
double
)
frac_count
));
if
(
unlikely
(
exp_overflow
))
{
if
(
value
==
0.0
)
return
value
;
if
(
exp_neg
)
return
neg
?
-
DBL_MIN
:
DBL_MIN
;
else
return
neg
?
-
DBL_MAX
:
DBL_MAX
;
}
if
(
exp_part
!=
0
)
if
(
exp_part
!=
0
)
{
{
if
(
exp_neg
)
if
(
exp_neg
)
...
@@ -167,7 +177,7 @@ struct DictOpSet : OpSet<Number>
...
@@ -167,7 +177,7 @@ struct DictOpSet : OpSet<Number>
if
(
part
!=
INT_PART
)
if
(
part
!=
INT_PART
)
{
{
substr
.
set_error
();
substr
.
set_error
();
return
v
;
return
v
alue
;
}
}
part
=
FRAC_PART
;
part
=
FRAC_PART
;
break
;
break
;
...
@@ -180,7 +190,7 @@ struct DictOpSet : OpSet<Number>
...
@@ -180,7 +190,7 @@ struct DictOpSet : OpSet<Number>
if
(
part
==
EXP_PART
)
if
(
part
==
EXP_PART
)
{
{
substr
.
set_error
();
substr
.
set_error
();
return
v
;
return
v
alue
;
}
}
part
=
EXP_PART
;
part
=
EXP_PART
;
break
;
break
;
...
@@ -193,18 +203,26 @@ struct DictOpSet : OpSet<Number>
...
@@ -193,18 +203,26 @@ struct DictOpSet : OpSet<Number>
break
;
break
;
case
FRAC_PART
:
case
FRAC_PART
:
frac_part
=
(
frac_part
*
10
)
+
d
;
if
(
likely
((
fract_count
<=
MAX_FRACT
/
10
)))
frac_count
++
;
{
frac_part
=
(
frac_part
*
10
)
+
d
;
frac_count
++
;
}
break
;
break
;
case
EXP_PART
:
case
EXP_PART
:
exp_part
=
(
exp_part
*
10
)
+
d
;
if
(
likely
(
exp_part
*
10
)
+
d
<=
MAX_EXP
)
{
exp_part
=
(
exp_part
*
10
)
+
d
;
}
else
exp_overflow
=
true
;
break
;
break
;
}
}
}
}
}
}
return
v
;
return
v
alue
;
}
}
static
inline
bool
is_hint_op
(
OpCode
op
)
static
inline
bool
is_hint_op
(
OpCode
op
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录