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
003c5e46
Commit
003c5e46
authored
Feb 22, 2016
by
Patrick Steinhardt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
transports: smart_pkt: fix memory leaks on error paths
parent
793e0855
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
10 deletions
+11
-10
src/transports/smart_pkt.c
+11
-10
No files found.
src/transports/smart_pkt.c
View file @
003c5e46
...
@@ -296,13 +296,12 @@ static int ng_pkt(git_pkt **out, const char *line, size_t len)
...
@@ -296,13 +296,12 @@ static int ng_pkt(git_pkt **out, const char *line, size_t len)
pkt
=
git__malloc
(
sizeof
(
*
pkt
));
pkt
=
git__malloc
(
sizeof
(
*
pkt
));
GITERR_CHECK_ALLOC
(
pkt
);
GITERR_CHECK_ALLOC
(
pkt
);
pkt
->
ref
=
NULL
;
pkt
->
type
=
GIT_PKT_NG
;
pkt
->
type
=
GIT_PKT_NG
;
line
+=
3
;
/* skip "ng " */
line
+=
3
;
/* skip "ng " */
if
(
!
(
ptr
=
strchr
(
line
,
' '
)))
{
if
(
!
(
ptr
=
strchr
(
line
,
' '
)))
giterr_set
(
GITERR_NET
,
"Invalid packet line"
);
goto
out_err
;
return
-
1
;
}
len
=
ptr
-
line
;
len
=
ptr
-
line
;
GITERR_CHECK_ALLOC_ADD
(
&
alloclen
,
len
,
1
);
GITERR_CHECK_ALLOC_ADD
(
&
alloclen
,
len
,
1
);
...
@@ -313,12 +312,8 @@ static int ng_pkt(git_pkt **out, const char *line, size_t len)
...
@@ -313,12 +312,8 @@ static int ng_pkt(git_pkt **out, const char *line, size_t len)
pkt
->
ref
[
len
]
=
'\0'
;
pkt
->
ref
[
len
]
=
'\0'
;
line
=
ptr
+
1
;
line
=
ptr
+
1
;
if
(
!
(
ptr
=
strchr
(
line
,
'\n'
)))
{
if
(
!
(
ptr
=
strchr
(
line
,
'\n'
)))
giterr_set
(
GITERR_NET
,
"Invalid packet line"
);
goto
out_err
;
git__free
(
pkt
->
ref
);
git__free
(
pkt
);
return
-
1
;
}
len
=
ptr
-
line
;
len
=
ptr
-
line
;
GITERR_CHECK_ALLOC_ADD
(
&
alloclen
,
len
,
1
);
GITERR_CHECK_ALLOC_ADD
(
&
alloclen
,
len
,
1
);
...
@@ -330,6 +325,12 @@ static int ng_pkt(git_pkt **out, const char *line, size_t len)
...
@@ -330,6 +325,12 @@ static int ng_pkt(git_pkt **out, const char *line, size_t len)
*
out
=
(
git_pkt
*
)
pkt
;
*
out
=
(
git_pkt
*
)
pkt
;
return
0
;
return
0
;
out_err:
giterr_set
(
GITERR_NET
,
"Invalid packet line"
);
git__free
(
pkt
->
ref
);
git__free
(
pkt
);
return
-
1
;
}
}
static
int
unpack_pkt
(
git_pkt
**
out
,
const
char
*
line
,
size_t
len
)
static
int
unpack_pkt
(
git_pkt
**
out
,
const
char
*
line
,
size_t
len
)
...
...
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