Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
a2ba34d3
Commit
a2ba34d3
authored
Dec 07, 2011
by
Scott Lawrence
Committed by
Russ Cox
Dec 07, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ld: fix memory leaks
R=golang-dev, rsc CC=golang-dev
https://golang.org/cl/5434068
parent
0c64972d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
3 deletions
+16
-3
src/cmd/ld/go.c
src/cmd/ld/go.c
+5
-2
src/cmd/ld/lib.c
src/cmd/ld/lib.c
+11
-1
No files found.
src/cmd/ld/go.c
View file @
a2ba34d3
...
@@ -235,7 +235,7 @@ loadpkgdata(char *file, char *pkg, char *data, int len)
...
@@ -235,7 +235,7 @@ loadpkgdata(char *file, char *pkg, char *data, int len)
x
=
ilookup
(
name
);
x
=
ilookup
(
name
);
if
(
x
->
prefix
==
nil
)
{
if
(
x
->
prefix
==
nil
)
{
x
->
prefix
=
prefix
;
x
->
prefix
=
prefix
;
x
->
def
=
def
;
x
->
def
=
strdup
(
def
)
;
x
->
file
=
file
;
x
->
file
=
file
;
}
else
if
(
strcmp
(
x
->
prefix
,
prefix
)
!=
0
)
{
}
else
if
(
strcmp
(
x
->
prefix
,
prefix
)
!=
0
)
{
fprint
(
2
,
"%s: conflicting definitions for %s
\n
"
,
argv0
,
name
);
fprint
(
2
,
"%s: conflicting definitions for %s
\n
"
,
argv0
,
name
);
...
@@ -248,7 +248,10 @@ loadpkgdata(char *file, char *pkg, char *data, int len)
...
@@ -248,7 +248,10 @@ loadpkgdata(char *file, char *pkg, char *data, int len)
fprint
(
2
,
"%s:
\t
%s %s %s
\n
"
,
file
,
prefix
,
name
,
def
);
fprint
(
2
,
"%s:
\t
%s %s %s
\n
"
,
file
,
prefix
,
name
,
def
);
nerrors
++
;
nerrors
++
;
}
}
free
(
name
);
free
(
def
);
}
}
free
(
file
);
}
}
// replace all "". with pkg.
// replace all "". with pkg.
...
@@ -264,7 +267,7 @@ expandpkg(char *t0, char *pkg)
...
@@ -264,7 +267,7 @@ expandpkg(char *t0, char *pkg)
n
++
;
n
++
;
if
(
n
==
0
)
if
(
n
==
0
)
return
t0
;
return
strdup
(
t0
)
;
// use malloc, not mal, so that caller can free
// use malloc, not mal, so that caller can free
w0
=
malloc
(
strlen
(
t0
)
+
strlen
(
pkg
)
*
n
);
w0
=
malloc
(
strlen
(
t0
)
+
strlen
(
pkg
)
*
n
);
...
...
src/cmd/ld/lib.c
View file @
a2ba34d3
...
@@ -351,6 +351,7 @@ objfile(char *file, char *pkg)
...
@@ -351,6 +351,7 @@ objfile(char *file, char *pkg)
Bseek
(
f
,
0L
,
0
);
Bseek
(
f
,
0L
,
0
);
ldobj
(
f
,
pkg
,
l
,
file
,
FileObj
);
ldobj
(
f
,
pkg
,
l
,
file
,
FileObj
);
Bterm
(
f
);
Bterm
(
f
);
free
(
pkg
);
return
;
return
;
}
}
...
@@ -412,6 +413,7 @@ objfile(char *file, char *pkg)
...
@@ -412,6 +413,7 @@ objfile(char *file, char *pkg)
out:
out:
Bterm
(
f
);
Bterm
(
f
);
free
(
pkg
);
}
}
void
void
...
@@ -439,14 +441,17 @@ ldobj(Biobuf *f, char *pkg, int64 len, char *pn, int whence)
...
@@ -439,14 +441,17 @@ ldobj(Biobuf *f, char *pkg, int64 len, char *pn, int whence)
magic
=
c1
<<
24
|
c2
<<
16
|
c3
<<
8
|
c4
;
magic
=
c1
<<
24
|
c2
<<
16
|
c3
<<
8
|
c4
;
if
(
magic
==
0x7f454c46
)
{
// \x7F E L F
if
(
magic
==
0x7f454c46
)
{
// \x7F E L F
ldelf
(
f
,
pkg
,
len
,
pn
);
ldelf
(
f
,
pkg
,
len
,
pn
);
free
(
pn
);
return
;
return
;
}
}
if
((
magic
&~
1
)
==
0xfeedface
||
(
magic
&~
0x01000000
)
==
0xcefaedfe
)
{
if
((
magic
&~
1
)
==
0xfeedface
||
(
magic
&~
0x01000000
)
==
0xcefaedfe
)
{
ldmacho
(
f
,
pkg
,
len
,
pn
);
ldmacho
(
f
,
pkg
,
len
,
pn
);
free
(
pn
);
return
;
return
;
}
}
if
(
c1
==
0x4c
&&
c2
==
0x01
||
c1
==
0x64
&&
c2
==
0x86
)
{
if
(
c1
==
0x4c
&&
c2
==
0x01
||
c1
==
0x64
&&
c2
==
0x86
)
{
ldpe
(
f
,
pkg
,
len
,
pn
);
ldpe
(
f
,
pkg
,
len
,
pn
);
free
(
pn
);
return
;
return
;
}
}
...
@@ -472,16 +477,18 @@ ldobj(Biobuf *f, char *pkg, int64 len, char *pn, int whence)
...
@@ -472,16 +477,18 @@ ldobj(Biobuf *f, char *pkg, int64 len, char *pn, int whence)
return
;
return
;
}
}
diag
(
"%s: not an object file"
,
pn
);
diag
(
"%s: not an object file"
,
pn
);
free
(
pn
);
return
;
return
;
}
}
// First, check that the basic goos, string, and version match.
// First, check that the basic goos, string, and version match.
t
=
smprint
(
"%s %s %s "
,
g
etgoos
()
,
thestring
,
getgoversion
());
t
=
smprint
(
"%s %s %s "
,
g
oos
,
thestring
,
getgoversion
());
line
[
n
]
=
' '
;
line
[
n
]
=
' '
;
if
(
strncmp
(
line
+
10
,
t
,
strlen
(
t
))
!=
0
&&
!
debug
[
'f'
])
{
if
(
strncmp
(
line
+
10
,
t
,
strlen
(
t
))
!=
0
&&
!
debug
[
'f'
])
{
line
[
n
]
=
'\0'
;
line
[
n
]
=
'\0'
;
diag
(
"%s: object is [%s] expected [%s]"
,
pn
,
line
+
10
,
t
);
diag
(
"%s: object is [%s] expected [%s]"
,
pn
,
line
+
10
,
t
);
free
(
t
);
free
(
t
);
free
(
pn
);
return
;
return
;
}
}
...
@@ -496,6 +503,7 @@ ldobj(Biobuf *f, char *pkg, int64 len, char *pn, int whence)
...
@@ -496,6 +503,7 @@ ldobj(Biobuf *f, char *pkg, int64 len, char *pn, int whence)
line
[
n
]
=
'\0'
;
line
[
n
]
=
'\0'
;
diag
(
"%s: object is [%s] expected [%s]"
,
pn
,
line
+
10
,
theline
);
diag
(
"%s: object is [%s] expected [%s]"
,
pn
,
line
+
10
,
theline
);
free
(
t
);
free
(
t
);
free
(
pn
);
return
;
return
;
}
}
}
}
...
@@ -521,10 +529,12 @@ ldobj(Biobuf *f, char *pkg, int64 len, char *pn, int whence)
...
@@ -521,10 +529,12 @@ ldobj(Biobuf *f, char *pkg, int64 len, char *pn, int whence)
Bseek
(
f
,
import1
,
0
);
Bseek
(
f
,
import1
,
0
);
ldobj1
(
f
,
pkg
,
eof
-
Boffset
(
f
),
pn
);
ldobj1
(
f
,
pkg
,
eof
-
Boffset
(
f
),
pn
);
free
(
pn
);
return
;
return
;
eof:
eof:
diag
(
"truncated object file: %s"
,
pn
);
diag
(
"truncated object file: %s"
,
pn
);
free
(
pn
);
}
}
static
Sym
*
static
Sym
*
...
...
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