Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
695067f7
Unverified
Commit
695067f7
authored
Sep 06, 2018
by
Patrick Steinhardt
Committed by
GitHub
Sep 06, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4792 from nelhage/multiline-leak
config: Fix a leak parsing multi-line config entries
parents
6f525a19
bc63e1ef
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
18 deletions
+25
-18
src/config_parse.c
+25
-18
No files found.
src/config_parse.c
View file @
695067f7
...
@@ -315,45 +315,52 @@ done:
...
@@ -315,45 +315,52 @@ done:
static
int
parse_multiline_variable
(
git_config_parser
*
reader
,
git_buf
*
value
,
int
in_quotes
)
static
int
parse_multiline_variable
(
git_config_parser
*
reader
,
git_buf
*
value
,
int
in_quotes
)
{
{
char
*
line
=
NULL
,
*
proc_line
=
NULL
;
int
quote_count
;
int
quote_count
;
bool
multiline
=
true
;
bool
multiline
=
true
;
while
(
multiline
)
{
while
(
multiline
)
{
char
*
line
=
NULL
,
*
proc_line
=
NULL
;
int
error
;
/* Check that the next line exists */
/* Check that the next line exists */
git_parse_advance_line
(
&
reader
->
ctx
);
git_parse_advance_line
(
&
reader
->
ctx
);
line
=
git__strndup
(
reader
->
ctx
.
line
,
reader
->
ctx
.
line_len
);
line
=
git__strndup
(
reader
->
ctx
.
line
,
reader
->
ctx
.
line_len
);
if
(
line
==
NULL
)
GITERR_CHECK_ALLOC
(
line
);
return
-
1
;
/* We've reached the end of the file, there is no continuation.
/*
* We've reached the end of the file, there is no continuation.
* (this is not an error).
* (this is not an error).
*/
*/
if
(
line
[
0
]
==
'\0'
)
{
if
(
line
[
0
]
==
'\0'
)
{
git__free
(
line
)
;
error
=
0
;
return
0
;
goto
out
;
}
}
/* If it was just a comment, pretend it didn't exist */
quote_count
=
strip_comments
(
line
,
!!
in_quotes
);
quote_count
=
strip_comments
(
line
,
!!
in_quotes
);
if
(
line
[
0
]
==
'\0'
)
goto
next
;
/* If it was just a comment, pretend it didn't exist */
if
((
error
=
unescape_line
(
&
proc_line
,
&
multiline
,
if
(
line
[
0
]
==
'\0'
)
{
line
,
in_quotes
))
<
0
)
in_quotes
=
quote_count
;
goto
out
;
continue
;
}
if
(
unescape_line
(
&
proc_line
,
&
multiline
,
line
,
in_quotes
)
<
0
)
{
/* Add this line to the multiline var */
git__free
(
line
);
if
((
error
=
git_buf_puts
(
value
,
proc_line
))
<
0
)
return
-
1
;
goto
out
;
}
/* add this line to the multiline var */
git_buf_puts
(
value
,
proc_line
);
next
:
git__free
(
line
);
git__free
(
line
);
git__free
(
proc_line
);
git__free
(
proc_line
);
in_quotes
=
quote_count
;
in_quotes
=
quote_count
;
continue
;
out
:
git__free
(
line
);
git__free
(
proc_line
);
return
error
;
}
}
return
0
;
return
0
;
}
}
...
...
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