Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-1.1
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
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
videolan
vlc-1.1
Commits
dfce44aa
Commit
dfce44aa
authored
Dec 15, 2008
by
Rémi Duraffort
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
* Fix memleak (#2352)
* Use NULL instead of 0 * cosmetics.
parent
e7754805
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
24 deletions
+41
-24
modules/misc/xml/xtag.c
modules/misc/xml/xtag.c
+41
-24
No files found.
modules/misc/xml/xtag.c
View file @
dfce44aa
...
...
@@ -193,26 +193,32 @@ static xml_reader_t *ReaderCreate( xml_t *p_xml, stream_t *s )
}
p_buffer
=
p_new
;
}
p_buffer
[
i_pos
+
i_size
]
=
0
;
/* 0 terminated string */
if
(
i_pos
+
i_size
==
0
)
{
msg_Dbg
(
p_xml
,
"empty XML"
);
free
(
p_buffer
);
return
0
;
return
NULL
;
}
p_buffer
[
i_pos
+
i_size
]
=
'\0'
;
/* 0 terminated string */
p_root
=
xtag_new_parse
(
p_buffer
,
i_buffer
);
if
(
!
p_root
)
{
msg_Warn
(
p_xml
,
"couldn't parse XML"
);
free
(
p_buffer
);
return
0
;
return
NULL
;
}
free
(
p_buffer
);
p_reader
=
malloc
(
sizeof
(
xml_reader_t
)
);
if
(
!
p_reader
)
return
NULL
;
p_reader
->
p_sys
=
malloc
(
sizeof
(
xml_reader_sys_t
)
);
if
(
!
p_reader
->
p_sys
)
{
free
(
p_reader
);
return
NULL
;
}
p_reader
->
p_sys
->
p_root
=
p_root
;
p_reader
->
p_sys
->
p_curtag
=
NULL
;
p_reader
->
p_sys
->
p_curattr
=
NULL
;
...
...
@@ -252,12 +258,12 @@ static int ReaderRead( xml_reader_t *p_reader )
return
1
;
}
while
(
1
)
while
(
true
)
{
if
(
(
p_child
=
xtag_next_child
(
p_reader
->
p_sys
->
p_curtag
,
0
))
)
{
p_reader
->
p_sys
->
p_curtag
=
p_child
;
p_reader
->
p_sys
->
p_curattr
=
0
;
p_reader
->
p_sys
->
p_curattr
=
NULL
;
p_reader
->
p_sys
->
b_endtag
=
false
;
return
1
;
}
...
...
@@ -279,10 +285,12 @@ static int ReaderRead( xml_reader_t *p_reader )
static
int
ReaderNodeType
(
xml_reader_t
*
p_reader
)
{
if
(
p_reader
->
p_sys
->
p_curtag
->
name
&&
p_reader
->
p_sys
->
b_endtag
)
return
XML_READER_ENDELEM
;
if
(
p_reader
->
p_sys
->
p_curtag
->
name
)
return
XML_READER_STARTELEM
;
if
(
p_reader
->
p_sys
->
p_curtag
->
pcdata
)
return
XML_READER_TEXT
;
if
(
p_reader
->
p_sys
->
p_curtag
->
name
&&
p_reader
->
p_sys
->
b_endtag
)
return
XML_READER_ENDELEM
;
if
(
p_reader
->
p_sys
->
p_curtag
->
name
)
return
XML_READER_STARTELEM
;
if
(
p_reader
->
p_sys
->
p_curtag
->
pcdata
)
return
XML_READER_TEXT
;
return
XML_READER_NONE
;
}
...
...
@@ -300,8 +308,7 @@ static char *ReaderName( xml_reader_t *p_reader )
else
psz_name
=
((
XAttribute
*
)
p_reader
->
p_sys
->
p_curattr
->
data
)
->
name
;
if
(
psz_name
)
return
strdup
(
psz_name
);
else
return
0
;
return
psz_name
?
strdup
(
psz_name
)
:
NULL
;
}
static
char
*
ReaderValue
(
xml_reader_t
*
p_reader
)
...
...
@@ -315,7 +322,7 @@ static char *ReaderValue( xml_reader_t *p_reader )
return
strdup
(
p_reader
->
p_sys
->
p_curtag
->
pcdata
);
}
if
(
!
p_reader
->
p_sys
->
p_curattr
)
return
0
;
if
(
!
p_reader
->
p_sys
->
p_curattr
)
return
NULL
;
#ifdef XTAG_DEBUG
fprintf
(
stderr
,
"%s=%s
\n
"
,
((
XAttribute
*
)
p_reader
->
p_sys
->
p_curattr
->
data
)
->
name
,
...
...
@@ -324,8 +331,7 @@ static char *ReaderValue( xml_reader_t *p_reader )
psz_name
=
((
XAttribute
*
)
p_reader
->
p_sys
->
p_curattr
->
data
)
->
value
;
if
(
psz_name
)
return
strdup
(
psz_name
);
else
return
0
;
return
psz_name
?
strdup
(
psz_name
)
:
NULL
;
}
static
int
ReaderNextAttr
(
xml_reader_t
*
p_reader
)
...
...
@@ -334,9 +340,8 @@ static int ReaderNextAttr( xml_reader_t *p_reader )
p_reader
->
p_sys
->
p_curattr
=
p_reader
->
p_sys
->
p_curtag
->
attributes
;
else
if
(
p_reader
->
p_sys
->
p_curattr
)
p_reader
->
p_sys
->
p_curattr
=
p_reader
->
p_sys
->
p_curattr
->
next
;
if
(
p_reader
->
p_sys
->
p_curattr
)
return
VLC_SUCCESS
;
else
return
VLC_EGENERIC
;
return
p_reader
->
p_sys
->
p_curattr
?
VLC_SUCCESS
:
VLC_EGENERIC
;
}
/*****************************************************************************
...
...
@@ -351,10 +356,14 @@ static XList *xlist_append( XList *list, void *data )
l
->
prev
=
l
->
next
=
NULL
;
l
->
data
=
data
;
if
(
list
==
NULL
)
return
l
;
if
(
!
list
)
return
l
;
for
(
last
=
list
;
last
;
last
=
last
->
next
)
if
(
last
->
next
==
NULL
)
break
;
{
if
(
!
last
->
next
)
break
;
}
if
(
last
)
last
->
next
=
l
;
l
->
prev
=
last
;
...
...
@@ -507,7 +516,11 @@ static char *xtag_slurp_quoted( XTagParser *parser )
ret
[
xi
]
=
'\0'
;
parser
->
start
=
&
s
[
xi
];
if
(
!
xtag_assert_and_pass
(
parser
,
quote
)
)
return
NULL
;
if
(
!
xtag_assert_and_pass
(
parser
,
quote
)
)
{
free
(
ret
);
return
NULL
;
}
return
ret
;
}
...
...
@@ -518,12 +531,14 @@ static XAttribute *xtag_parse_attribute( XTagParser *parser )
char
*
name
,
*
value
;
char
*
s
;
if
(
!
parser
->
valid
)
return
NULL
;
if
(
!
parser
->
valid
)
return
NULL
;
xtag_skip_whitespace
(
parser
);
name
=
xtag_slurp_to
(
parser
,
X_WHITESPACE
|
X_EQUAL
,
X_SLASH
|
X_CLOSETAG
);
if
(
name
==
NULL
)
return
NULL
;
if
(
!
name
)
return
NULL
;
xtag_skip_whitespace
(
parser
);
s
=
parser
->
start
;
...
...
@@ -747,7 +762,8 @@ static XTag *xtag_free( XTag *xtag )
XAttribute
*
attr
;
XTag
*
child
;
if
(
xtag
==
NULL
)
return
NULL
;
if
(
!
xtag
)
return
NULL
;
free
(
xtag
->
name
);
free
(
xtag
->
pcdata
);
...
...
@@ -1052,3 +1068,4 @@ static int xtag_snprint( char *buf, int n, XTag *xtag )
return
written
;
}
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