Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
asn1c
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
asn1c
Commits
fbbe4edc
Commit
fbbe4edc
authored
Mar 26, 2017
by
Lev Walkin
Committed by
GitHub
Mar 26, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #126 from brchiu/fix_some_leak_reported_by_valgrind
Fix many memory leaks reported by valgrind
parents
46fc2bd8
4661dae4
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
102 additions
and
5 deletions
+102
-5
asn1c/asn1c.c
asn1c/asn1c.c
+7
-0
libasn1compiler/asn1c_C.c
libasn1compiler/asn1c_C.c
+9
-0
libasn1compiler/asn1c_constraint.c
libasn1compiler/asn1c_constraint.c
+9
-3
libasn1compiler/asn1c_fdeps.c
libasn1compiler/asn1c_fdeps.c
+32
-2
libasn1compiler/asn1c_fdeps.h
libasn1compiler/asn1c_fdeps.h
+1
-0
libasn1compiler/asn1c_save.c
libasn1compiler/asn1c_save.c
+3
-0
libasn1compiler/asn1compiler.c
libasn1compiler/asn1compiler.c
+29
-0
libasn1parser/asn1p_expr.c
libasn1parser/asn1p_expr.c
+7
-0
libasn1parser/asn1p_expr.h
libasn1parser/asn1p_expr.h
+1
-0
libasn1parser/asn1p_module.c
libasn1parser/asn1p_module.c
+1
-0
libasn1parser/asn1p_oid.c
libasn1parser/asn1p_oid.c
+1
-0
libasn1parser/asn1p_value.c
libasn1parser/asn1p_value.c
+2
-0
No files found.
asn1c/asn1c.c
View file @
fbbe4edc
...
...
@@ -330,6 +330,8 @@ main(int ac, char **av) {
exit
(
EX_SOFTWARE
);
}
asn1p_delete
(
asn
);
return
0
;
}
...
...
@@ -423,6 +425,11 @@ importStandardModules(asn1p_t *asn, const char *skeletons_dir) {
closedir
(
dir
);
#endif
#ifdef _WIN32
free
(
pattern
);
#endif
free
(
target_dir
);
return
ret
;
}
...
...
libasn1compiler/asn1c_C.c
View file @
fbbe4edc
...
...
@@ -507,6 +507,8 @@ asn1c_lang_C_type_SEQUENCE_def(arg_t *arg) {
REDIR
(
saved_target
);
if
(
tag2el
)
free
(
tag2el
);
return
0
;
}
/* _SEQUENCE_def() */
...
...
@@ -741,6 +743,9 @@ asn1c_lang_C_type_SET_def(arg_t *arg) {
REDIR
(
saved_target
);
if
(
tag2el
)
free
(
tag2el
);
if
(
tag2el_cxer
)
free
(
tag2el_cxer
);
return
0
;
}
/* _SET_def() */
...
...
@@ -874,6 +879,8 @@ asn1c_lang_C_type_SEx_OF_def(arg_t *arg, int seq_of) {
arg
->
embed
++
;
emit_member_table
(
arg
,
v
);
arg
->
embed
--
;
free
(
v
->
Identifier
);
v
->
Identifier
=
(
char
*
)
NULL
;
INDENT
(
-
1
);
OUT
(
"};
\n
"
);
...
...
@@ -1113,6 +1120,8 @@ asn1c_lang_C_type_CHOICE_def(arg_t *arg) {
REDIR
(
saved_target
);
if
(
tag2el
)
free
(
tag2el
);
return
0
;
}
/* _CHOICE_def() */
...
...
libasn1compiler/asn1c_constraint.c
View file @
fbbe4edc
...
...
@@ -35,6 +35,7 @@ asn1c_emit_constraint_checking_code(arg_t *arg) {
int
alphabet_table_compiled
;
int
produce_st
=
0
;
int
ulong_optimize
=
0
;
int
ret
=
0
;
ct
=
expr
->
combined_constraints
;
if
(
ct
==
NULL
)
...
...
@@ -158,7 +159,7 @@ asn1c_emit_constraint_checking_code(arg_t *arg) {
OUT
(
"
\n
"
);
OUT
(
"/* Constraint check succeeded */
\n
"
);
OUT
(
"return 0;
\n
"
);
return
0
;
goto
end
;
}
/*
...
...
@@ -197,7 +198,8 @@ asn1c_emit_constraint_checking_code(arg_t *arg) {
INDENTED
(
OUT
(
"/* Nothing is here. See below */
\n
"
));
OUT
(
"}
\n
"
);
OUT
(
"
\n
"
);
return
1
;
ret
=
1
;
goto
end
;
}
INDENT
(
-
1
);
OUT
(
") {
\n
"
);
...
...
@@ -222,7 +224,11 @@ asn1c_emit_constraint_checking_code(arg_t *arg) {
INDENT
(
-
1
);
OUT
(
"}
\n
"
);
return
0
;
end:
if
(
r_value
)
asn1constraint_range_free
(
r_value
);
if
(
r_size
)
asn1constraint_range_free
(
r_size
);
return
ret
;
}
static
int
...
...
libasn1compiler/asn1c_fdeps.c
View file @
fbbe4edc
...
...
@@ -140,6 +140,16 @@ asn1c_new_dep(const char *filename) {
return
d
;
}
static
void
asn1c_free_dep
(
asn1c_fdeps_t
*
d
)
{
if
(
d
)
{
if
(
d
->
filename
)
free
(
d
->
filename
);
d
->
filename
=
0
;
free
(
d
);
}
}
static
int
asn1c_dep_add
(
asn1c_fdeps_t
*
deps
,
asn1c_fdeps_t
*
d
)
{
int
n
;
...
...
@@ -180,7 +190,9 @@ asn1c_deps_makelist(asn1c_fdeps_t *deps) {
if
(
deps
->
filename
&&
deps
->
usage
!=
FDEP_NOTUSED
)
{
d
=
asn1c_new_dep
(
deps
->
filename
);
d
->
usage
=
deps
->
usage
;
asn1c_dep_add
(
dlist
,
d
);
if
(
!
asn1c_dep_add
(
dlist
,
d
))
{
asn1c_free_dep
(
d
);
}
}
for
(
i
=
0
;
i
<
deps
->
el_count
;
i
++
)
{
...
...
@@ -188,10 +200,28 @@ asn1c_deps_makelist(asn1c_fdeps_t *deps) {
d
=
asn1c_deps_makelist
(
deps
->
elements
[
i
]);
assert
(
!
d
->
filename
);
for
(
j
=
0
;
j
<
d
->
el_count
;
j
++
)
{
asn1c_dep_add
(
dlist
,
d
->
elements
[
j
]);
if
(
asn1c_dep_add
(
dlist
,
d
->
elements
[
j
]))
{
d
->
elements
[
j
]
=
0
;
}
}
asn1c_deps_freelist
(
d
);
}
return
dlist
;
}
void
asn1c_deps_freelist
(
asn1c_fdeps_t
*
deps
)
{
if
(
deps
)
{
int
i
;
if
(
deps
->
elements
)
{
for
(
i
=
0
;
i
<
deps
->
el_count
;
i
++
)
{
asn1c_deps_freelist
(
deps
->
elements
[
i
]);
deps
->
elements
[
i
]
=
0
;
}
free
(
deps
->
elements
);
deps
->
elements
=
0
;
}
asn1c_free_dep
(
deps
);
}
}
libasn1compiler/asn1c_fdeps.h
View file @
fbbe4edc
...
...
@@ -25,5 +25,6 @@ int asn1c_activate_dependency(asn1c_fdeps_t *deps, asn1c_fdeps_t *cur,
const
char
*
data
);
asn1c_fdeps_t
*
asn1c_deps_makelist
(
asn1c_fdeps_t
*
deps
);
void
asn1c_deps_freelist
(
asn1c_fdeps_t
*
deps
);
#endif
/* ASN1C_FDEPS_H */
libasn1compiler/asn1c_save.c
View file @
fbbe4edc
...
...
@@ -149,6 +149,9 @@ asn1c_save_compiled_output(arg_t *arg, const char *datadir,
safe_fprintf
(
mkf
,
"ASN_%s_%s+=%s
\n
"
,
what_class
,
what_kind
,
fname
);
}
asn1c_deps_freelist
(
deps
);
asn1c_deps_freelist
(
dlist
);
}
if
(
need_to_generate_pdu_collection
(
arg
))
{
...
...
libasn1compiler/asn1compiler.c
View file @
fbbe4edc
...
...
@@ -6,6 +6,7 @@
static
void
default_logger_cb
(
int
,
const
char
*
fmt
,
...);
static
int
asn1c_compile_expr
(
arg_t
*
arg
);
static
int
asn1c_attach_streams
(
asn1p_expr_t
*
expr
);
static
int
asn1c_detach_streams
(
asn1p_expr_t
*
expr
);
int
asn1_compile
(
asn1p_t
*
asn
,
const
char
*
datadir
,
enum
asn1c_flags
flags
,
...
...
@@ -61,6 +62,12 @@ asn1_compile(asn1p_t *asn, const char *datadir, enum asn1c_flags flags,
if
(
asn1c_save_compiled_output
(
arg
,
datadir
,
argc
,
optc
,
argv
))
return
-
1
;
TQ_FOR
(
mod
,
&
(
asn
->
modules
),
mod_next
)
{
TQ_FOR
(
arg
->
expr
,
&
(
mod
->
members
),
next
)
{
asn1c_detach_streams
(
arg
->
expr
);
}
}
return
0
;
}
...
...
@@ -159,6 +166,28 @@ asn1c_attach_streams(asn1p_expr_t *expr) {
return
0
;
}
int
asn1c_detach_streams
(
asn1p_expr_t
*
expr
)
{
compiler_streams_t
*
cs
;
out_chunk_t
*
m
;
int
i
;
if
(
!
expr
->
data
)
return
0
;
/* Already detached? */
cs
=
expr
->
data
;
for
(
i
=
0
;
i
<
OT_MAX
;
i
++
)
{
while
((
m
=
TQ_REMOVE
(
&
(
cs
->
destination
[
i
].
chunks
),
next
)))
{
free
(
m
->
buf
);
free
(
m
);
}
}
free
(
expr
->
data
);
expr
->
data
=
(
void
*
)
NULL
;
return
0
;
}
static
void
default_logger_cb
(
int
_severity
,
const
char
*
fmt
,
...)
{
va_list
ap
;
...
...
libasn1parser/asn1p_expr.c
View file @
fbbe4edc
...
...
@@ -22,6 +22,7 @@ asn1p_expr_new(int _lineno, asn1p_module_t *mod) {
expr
->
spec_index
=
-
1
;
expr
->
module
=
mod
;
expr
->
_lineno
=
_lineno
;
expr
->
ref_cnt
=
0
;
}
return
expr
;
...
...
@@ -235,6 +236,12 @@ asn1p_expr_free(asn1p_expr_t *expr) {
if
(
expr
)
{
asn1p_expr_t
*
tm
;
if
(
expr
->
ref_cnt
)
{
/* Decrease reference count only */
expr
->
ref_cnt
--
;
return
;
}
/* Remove all children */
while
((
tm
=
TQ_REMOVE
(
&
(
expr
->
members
),
next
)))
{
if
(
tm
->
parent_expr
!=
expr
)
...
...
libasn1parser/asn1p_expr.h
View file @
fbbe4edc
...
...
@@ -216,6 +216,7 @@ typedef struct asn1p_expr_s {
asn1p_value_t
*
default_value
;
/* For EM_DEFAULT case */
}
marker
;
int
unique
;
/* UNIQUE */
int
ref_cnt
;
/* reference count */
/*
* Whether automatic tagging may be applied for subtypes.
...
...
libasn1parser/asn1p_module.c
View file @
fbbe4edc
...
...
@@ -28,6 +28,7 @@ asn1p_module_free(asn1p_module_t *mod) {
asn1p_expr_t
*
expr
;
free
(
mod
->
ModuleName
);
free
(
mod
->
source_file_name
);
asn1p_oid_free
(
mod
->
module_oid
);
...
...
libasn1parser/asn1p_oid.c
View file @
fbbe4edc
...
...
@@ -52,6 +52,7 @@ asn1p_oid_free(asn1p_oid_t *oid) {
while
(
oid
->
arcs_count
--
)
{
free
(
oid
->
arcs
[
oid
->
arcs_count
].
name
);
}
free
(
oid
->
arcs
);
}
free
(
oid
);
}
...
...
libasn1parser/asn1p_value.c
View file @
fbbe4edc
...
...
@@ -138,6 +138,7 @@ asn1p_value_fromtype(asn1p_expr_t *expr) {
if
(
v
)
{
v
->
value
.
v_type
=
expr
;
v
->
type
=
ATV_TYPE
;
expr
->
ref_cnt
++
;
}
return
v
;
}
...
...
@@ -258,6 +259,7 @@ asn1p_value_free(asn1p_value_t *v) {
asn1p_value_free
(
v
->
value
.
choice_identifier
.
value
);
break
;
}
memset
(
v
,
0
,
sizeof
(
*
v
));
free
(
v
);
}
}
...
...
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