Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Harfbuzz
提交
20e3dd5d
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看板
提交
20e3dd5d
编写于
5月 04, 2010
作者:
B
Behdad Esfahbod
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make sanitize_depth variable automatic and not passed through function args
上级
4a446ac3
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
43 addition
and
29 deletion
+43
-29
src/hb-open-type-private.hh
src/hb-open-type-private.hh
+43
-29
未找到文件。
src/hb-open-type-private.hh
浏览文件 @
20e3dd5d
...
...
@@ -112,6 +112,26 @@ ASSERT_STATIC (sizeof (Type) + 1 <= sizeof (_Null##Type))
#define Null(Type) Null<Type>()
/*
* Debug
*/
/* Helper object to increment debug_depth and decrement
* when returning from the object. */
template
<
int
debug_level
>
struct
hb_auto_debug_depth_t
{
explicit
hb_auto_debug_depth_t
(
unsigned
int
*
p
)
:
p
(
p
)
{
++*
p
;
}
~
hb_auto_debug_depth_t
(
void
)
{
--*
p
;
}
private:
unsigned
int
*
p
;
};
template
<
>
/* Optimize when debugging is disabled */
struct
hb_auto_debug_depth_t
<
0
>
{
explicit
hb_auto_debug_depth_t
(
unsigned
int
*
p
)
{}
};
/*
* Sanitize
...
...
@@ -121,19 +141,17 @@ ASSERT_STATIC (sizeof (Type) + 1 <= sizeof (_Null##Type))
#define HB_DEBUG_SANITIZE HB_DEBUG+0
#endif
#define TRACE_SANITIZE() \
HB_STMT_START { \
if (HB_DEBUG_SANITIZE) \
_hb_trace ("SANITIZE", HB_FUNC, this, sanitize_depth, HB_DEBUG_SANITIZE); \
} HB_STMT_END
hb_auto_debug_depth_t<HB_DEBUG_SANITIZE> auto_debug_depth (&context->debug_depth); \
if (HB_DEBUG_SANITIZE) \
_hb_trace ("SANITIZE", HB_FUNC, this, context->debug_depth, HB_DEBUG_SANITIZE); \
#define SANITIZE_ARG_DEF \
hb_sanitize_context_t *context, \
unsigned int sanitize_depth HB_UNUSED
hb_sanitize_context_t *context
#define SANITIZE_ARG \
context, \
(HB_DEBUG_SANITIZE ? sanitize_depth + 1 : 0)
context
struct
hb_sanitize_context_t
{
...
...
@@ -144,6 +162,7 @@ struct hb_sanitize_context_t
this
->
end
=
this
->
start
+
hb_blob_get_length
(
blob
);
this
->
writable
=
hb_blob_is_writable
(
blob
);
this
->
edit_count
=
0
;
this
->
debug_depth
=
0
;
if
(
HB_DEBUG_SANITIZE
)
fprintf
(
stderr
,
"sanitize %p init [%p..%p] (%u bytes)
\n
"
,
...
...
@@ -162,18 +181,16 @@ struct hb_sanitize_context_t
this
->
start
=
this
->
end
=
NULL
;
}
inline
bool
check
(
unsigned
int
sanitize_depth
,
const
char
*
base
,
unsigned
int
len
)
const
inline
bool
check
(
const
char
*
base
,
unsigned
int
len
)
const
{
bool
ret
=
this
->
start
<=
base
&&
base
<=
this
->
end
&&
(
unsigned
int
)
(
this
->
end
-
base
)
>=
len
;
if
(
HB_DEBUG_SANITIZE
&&
(
int
)
sanitize
_depth
<
(
int
)
HB_DEBUG_SANITIZE
)
\
if
(
HB_DEBUG_SANITIZE
&&
(
int
)
this
->
debug
_depth
<
(
int
)
HB_DEBUG_SANITIZE
)
\
fprintf
(
stderr
,
"SANITIZE(%p) %-*d-> check [%p..%p] (%d bytes) in [%p..%p] -> %s
\n
"
,
\
base
,
sanitize_depth
,
sanitize
_depth
,
this
->
debug_depth
,
this
->
debug
_depth
,
base
,
base
+
len
,
len
,
this
->
start
,
this
->
end
,
ret
?
"pass"
:
"FAIL"
);
...
...
@@ -181,35 +198,30 @@ struct hb_sanitize_context_t
return
ret
;
}
inline
bool
check_array
(
unsigned
int
sanitize_depth
,
const
char
*
base
,
unsigned
int
record_size
,
unsigned
int
len
)
const
inline
bool
check_array
(
const
char
*
base
,
unsigned
int
record_size
,
unsigned
int
len
)
const
{
bool
overflows
=
len
>=
((
unsigned
int
)
-
1
)
/
record_size
;
if
(
HB_DEBUG_SANITIZE
&&
(
int
)
sanitize
_depth
<
(
int
)
HB_DEBUG_SANITIZE
)
if
(
HB_DEBUG_SANITIZE
&&
(
int
)
this
->
debug
_depth
<
(
int
)
HB_DEBUG_SANITIZE
)
fprintf
(
stderr
,
"SANITIZE(%p) %-*d-> array [%p..%p] (%d*%d=%ld bytes) in [%p..%p] -> %s
\n
"
,
\
base
,
sanitize_depth
,
sanitize
_depth
,
this
->
debug_depth
,
this
->
debug
_depth
,
base
,
base
+
(
record_size
*
len
),
record_size
,
len
,
(
unsigned
long
)
record_size
*
len
,
this
->
start
,
this
->
end
,
!
overflows
?
"does not overflow"
:
"OVERFLOWS FAIL"
);
return
likely
(
!
overflows
)
&&
this
->
check
(
sanitize_depth
,
base
,
record_size
*
len
);
return
likely
(
!
overflows
)
&&
this
->
check
(
base
,
record_size
*
len
);
}
inline
bool
can_edit
(
unsigned
int
sanitize_depth
,
const
char
*
base
HB_UNUSED
,
unsigned
int
len
HB_UNUSED
)
inline
bool
can_edit
(
const
char
*
base
HB_UNUSED
,
unsigned
int
len
HB_UNUSED
)
{
this
->
edit_count
++
;
if
(
HB_DEBUG_SANITIZE
&&
(
int
)
sanitize
_depth
<
(
int
)
HB_DEBUG_SANITIZE
)
if
(
HB_DEBUG_SANITIZE
&&
(
int
)
this
->
debug
_depth
<
(
int
)
HB_DEBUG_SANITIZE
)
fprintf
(
stderr
,
"SANITIZE(%p) %-*d-> edit(%u) [%p..%p] (%d bytes) in [%p..%p] -> %s
\n
"
,
\
base
,
sanitize_depth
,
sanitize
_depth
,
this
->
debug_depth
,
this
->
debug
_depth
,
this
->
edit_count
,
base
,
base
+
len
,
len
,
this
->
start
,
this
->
end
,
...
...
@@ -225,6 +237,9 @@ struct hb_sanitize_context_t
inline
void
reset_edit_count
(
void
)
{
this
->
edit_count
=
0
;
}
public:
unsigned
int
debug_depth
;
private:
const
char
*
start
,
*
end
;
bool
writable
;
...
...
@@ -239,9 +254,9 @@ struct hb_sanitize_context_t
#define SANITIZE_SELF() SANITIZE_MEM(this, sizeof (*this))
#define SANITIZE_MEM(B,L) likely (context->check (
sanitize_depth,
CharP(B), (L)))
#define SANITIZE_MEM(B,L) likely (context->check (CharP(B), (L)))
#define SANITIZE_ARRAY(A,S,L) likely (context->check_array (
sanitize_depth,
CharP(A), S, L))
#define SANITIZE_ARRAY(A,S,L) likely (context->check_array (CharP(A), S, L))
/* Template to sanitize an object. */
...
...
@@ -250,7 +265,6 @@ struct Sanitizer
{
static
hb_blob_t
*
sanitize
(
hb_blob_t
*
blob
)
{
hb_sanitize_context_t
context
[
1
];
unsigned
int
sanitize_depth
=
0
;
bool
sane
;
/* TODO is_sane() stuff */
...
...
@@ -464,7 +478,7 @@ struct GenericOffsetTo : OffsetType
private:
/* Set the offset to Null */
inline
bool
neuter
(
SANITIZE_ARG_DEF
)
{
if
(
context
->
can_edit
(
sanitize_depth
,
CharP
(
this
),
this
->
get_size
()))
{
if
(
context
->
can_edit
(
CharP
(
this
),
this
->
get_size
()))
{
this
->
set
(
0
);
/* 0 is Null offset */
return
true
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录