Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
be707384
T
Third Party Harfbuzz
项目概览
OpenHarmony
/
Third Party Harfbuzz
大约 1 年 前同步成功
通知
0
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
be707384
编写于
7月 17, 2018
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Move sanitizer code around a bit
上级
db5d430e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
58 addition
and
56 deletion
+58
-56
src/hb-aat-layout-common-private.hh
src/hb-aat-layout-common-private.hh
+2
-2
src/hb-open-type-private.hh
src/hb-open-type-private.hh
+52
-43
src/hb-ot-color-sbix-table.hh
src/hb-ot-color-sbix-table.hh
+4
-8
src/hb-ot-layout-common-private.hh
src/hb-ot-layout-common-private.hh
+0
-3
未找到文件。
src/hb-aat-layout-common-private.hh
浏览文件 @
be707384
...
@@ -161,7 +161,7 @@ struct LookupFormat0
...
@@ -161,7 +161,7 @@ struct LookupFormat0
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
)
const
inline
bool
sanitize
(
hb_sanitize_context_t
*
c
)
const
{
{
TRACE_SANITIZE
(
this
);
TRACE_SANITIZE
(
this
);
return_trace
(
arrayZ
.
sanitize
(
c
,
c
->
num_glyphs
));
return_trace
(
arrayZ
.
sanitize
(
c
,
c
->
get_num_glyphs
()
));
}
}
protected:
protected:
...
@@ -625,7 +625,7 @@ struct hb_aat_apply_context_t :
...
@@ -625,7 +625,7 @@ struct hb_aat_apply_context_t :
sanitizer
(),
lookup_index
(
0
),
debug_depth
(
0
)
sanitizer
(),
lookup_index
(
0
),
debug_depth
(
0
)
{
{
sanitizer
.
init
(
table
);
sanitizer
.
init
(
table
);
sanitizer
.
num_glyphs
=
face
->
get_num_glyphs
(
);
sanitizer
.
set_num_glyphs
(
face
->
get_num_glyphs
()
);
sanitizer
.
start_processing
();
sanitizer
.
start_processing
();
}
}
...
...
src/hb-open-type-private.hh
浏览文件 @
be707384
...
@@ -182,6 +182,9 @@ struct hb_sanitize_context_t :
...
@@ -182,6 +182,9 @@ struct hb_sanitize_context_t :
this
->
writable
=
false
;
this
->
writable
=
false
;
}
}
inline
void
set_num_glyphs
(
unsigned
int
num_glyphs_
)
{
num_glyphs
=
num_glyphs_
;
}
inline
unsigned
int
get_num_glyphs
(
void
)
{
return
num_glyphs
;
}
inline
void
start_processing
(
void
)
inline
void
start_processing
(
void
)
{
{
this
->
start
=
hb_blob_get_data
(
this
->
blob
,
nullptr
);
this
->
start
=
hb_blob_get_data
(
this
->
blob
,
nullptr
);
...
@@ -275,74 +278,63 @@ struct hb_sanitize_context_t :
...
@@ -275,74 +278,63 @@ struct hb_sanitize_context_t :
return
false
;
return
false
;
}
}
mutable
unsigned
int
debug_depth
;
template
<
typename
Type
>
const
char
*
start
,
*
end
;
bool
writable
;
unsigned
int
edit_count
;
mutable
int
max_ops
;
hb_blob_t
*
blob
;
unsigned
int
num_glyphs
;
};
/* Template to sanitize an object. */
template
<
typename
Type
>
struct
Sanitizer
{
inline
Sanitizer
(
unsigned
int
num_glyphs
=
0
)
{
c
->
num_glyphs
=
num_glyphs
;
}
inline
hb_blob_t
*
sanitize
(
hb_blob_t
*
blob
)
inline
hb_blob_t
*
sanitize
(
hb_blob_t
*
blob
)
{
{
bool
sane
;
bool
sane
;
/* TODO is_sane() stuff */
/* TODO is_sane() stuff */
c
->
init
(
blob
);
init
(
blob
);
retry:
retry:
DEBUG_MSG_FUNC
(
SANITIZE
,
c
->
start
,
"start"
);
DEBUG_MSG_FUNC
(
SANITIZE
,
start
,
"start"
);
c
->
start_processing
();
start_processing
();
if
(
unlikely
(
!
c
->
start
))
{
if
(
unlikely
(
!
start
))
c
->
end_processing
();
{
end_processing
();
return
blob
;
return
blob
;
}
}
Type
*
t
=
CastP
<
Type
>
(
const_cast
<
char
*>
(
c
->
start
));
Type
*
t
=
CastP
<
Type
>
(
const_cast
<
char
*>
(
start
));
sane
=
t
->
sanitize
(
c
);
sane
=
t
->
sanitize
(
this
);
if
(
sane
)
{
if
(
sane
)
if
(
c
->
edit_count
)
{
{
DEBUG_MSG_FUNC
(
SANITIZE
,
c
->
start
,
"passed first round with %d edits; going for second round"
,
c
->
edit_count
);
if
(
edit_count
)
{
DEBUG_MSG_FUNC
(
SANITIZE
,
start
,
"passed first round with %d edits; going for second round"
,
edit_count
);
/* sanitize again to ensure no toe-stepping */
/* sanitize again to ensure no toe-stepping */
c
->
edit_count
=
0
;
edit_count
=
0
;
sane
=
t
->
sanitize
(
c
);
sane
=
t
->
sanitize
(
this
);
if
(
c
->
edit_count
)
{
if
(
edit_count
)
{
DEBUG_MSG_FUNC
(
SANITIZE
,
c
->
start
,
"requested %d edits in second round; FAILLING"
,
c
->
edit_count
);
DEBUG_MSG_FUNC
(
SANITIZE
,
start
,
"requested %d edits in second round; FAILLING"
,
edit_count
);
sane
=
false
;
sane
=
false
;
}
}
}
}
}
else
{
}
unsigned
int
edit_count
=
c
->
edit_count
;
else
if
(
edit_count
&&
!
c
->
writable
)
{
{
c
->
start
=
hb_blob_get_data_writable
(
blob
,
nullptr
);
if
(
edit_count
&&
!
writable
)
{
c
->
end
=
c
->
start
+
blob
->
length
;
start
=
hb_blob_get_data_writable
(
blob
,
nullptr
);
end
=
start
+
blob
->
length
;
if
(
c
->
start
)
{
c
->
writable
=
true
;
if
(
start
)
{
writable
=
true
;
/* ok, we made it writable by relocating. try again */
/* ok, we made it writable by relocating. try again */
DEBUG_MSG_FUNC
(
SANITIZE
,
c
->
start
,
"retry"
);
DEBUG_MSG_FUNC
(
SANITIZE
,
start
,
"retry"
);
goto
retry
;
goto
retry
;
}
}
}
}
}
}
c
->
end_processing
();
end_processing
();
DEBUG_MSG_FUNC
(
SANITIZE
,
c
->
start
,
sane
?
"PASSED"
:
"FAILED"
);
DEBUG_MSG_FUNC
(
SANITIZE
,
start
,
sane
?
"PASSED"
:
"FAILED"
);
if
(
sane
)
if
(
sane
)
{
{
blob
->
lock
();
blob
->
lock
();
...
@@ -355,7 +347,24 @@ struct Sanitizer
...
@@ -355,7 +347,24 @@ struct Sanitizer
}
}
}
}
inline
void
set_num_glyphs
(
unsigned
int
num_glyphs
)
{
c
->
num_glyphs
=
num_glyphs
;
}
mutable
unsigned
int
debug_depth
;
const
char
*
start
,
*
end
;
private:
bool
writable
;
unsigned
int
edit_count
;
mutable
int
max_ops
;
hb_blob_t
*
blob
;
unsigned
int
num_glyphs
;
};
/* Template to sanitize an object. */
template
<
typename
Type
>
struct
Sanitizer
{
inline
Sanitizer
(
unsigned
int
num_glyphs
=
0
)
{
c
->
set_num_glyphs
(
num_glyphs
);
}
inline
hb_blob_t
*
sanitize
(
hb_blob_t
*
blob
)
{
return
c
->
sanitize
<
Type
>
(
blob
);
}
private:
private:
hb_sanitize_context_t
c
[
1
];
hb_sanitize_context_t
c
[
1
];
...
...
src/hb-ot-color-sbix-table.hh
浏览文件 @
be707384
...
@@ -68,7 +68,7 @@ struct SBIXStrike
...
@@ -68,7 +68,7 @@ struct SBIXStrike
{
{
TRACE_SANITIZE
(
this
);
TRACE_SANITIZE
(
this
);
return_trace
(
c
->
check_struct
(
this
)
&&
return_trace
(
c
->
check_struct
(
this
)
&&
imageOffsetsZ
.
sanitize_shallow
(
c
,
c
->
num_glyphs
+
1
));
imageOffsetsZ
.
sanitize_shallow
(
c
,
c
->
get_num_glyphs
()
+
1
));
}
}
protected:
protected:
...
@@ -96,14 +96,11 @@ struct sbix
...
@@ -96,14 +96,11 @@ struct sbix
{
{
inline
void
init
(
hb_face_t
*
face
)
inline
void
init
(
hb_face_t
*
face
)
{
{
num_glyphs
=
hb_face_get_glyph_count
(
face
);
/* XXX Using public API instead of private method to avoid link problem in dump_emoji.
* Kill that! */
OT
::
Sanitizer
<
OT
::
sbix
>
sanitizer
;
sbix_blob
=
OT
::
Sanitizer
<
OT
::
sbix
>
(
hb_face_get_glyph_count
(
face
)
/*face->get_num_glyphs ()*/
).
sanitize
(
face
->
reference_table
(
HB_OT_TAG_sbix
));
sanitizer
.
set_num_glyphs
(
num_glyphs
);
sbix_blob
=
sanitizer
.
sanitize
(
face
->
reference_table
(
HB_OT_TAG_sbix
));
sbix_len
=
hb_blob_get_length
(
sbix_blob
);
sbix_len
=
hb_blob_get_length
(
sbix_blob
);
sbix_table
=
sbix_blob
->
as
<
OT
::
sbix
>
();
sbix_table
=
sbix_blob
->
as
<
OT
::
sbix
>
();
}
}
inline
void
fini
(
void
)
inline
void
fini
(
void
)
...
@@ -134,7 +131,6 @@ struct sbix
...
@@ -134,7 +131,6 @@ struct sbix
unsigned
int
sbix_len
;
unsigned
int
sbix_len
;
unsigned
int
num_glyphs
;
unsigned
int
num_glyphs
;
};
};
protected:
protected:
...
...
src/hb-ot-layout-common-private.hh
浏览文件 @
be707384
...
@@ -540,9 +540,6 @@ struct Feature
...
@@ -540,9 +540,6 @@ struct Feature
c
->
try_set
(
&
featureParams
,
new_offset
)
&&
c
->
try_set
(
&
featureParams
,
new_offset
)
&&
!
featureParams
.
sanitize
(
c
,
this
,
closure
?
closure
->
tag
:
HB_TAG_NONE
))
!
featureParams
.
sanitize
(
c
,
this
,
closure
?
closure
->
tag
:
HB_TAG_NONE
))
return_trace
(
false
);
return_trace
(
false
);
if
(
c
->
edit_count
>
1
)
c
->
edit_count
--
;
/* This was a "legitimate" edit; don't contribute to error count. */
}
}
return_trace
(
true
);
return_trace
(
true
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录