Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
fc4ba154
Commit
fc4ba154
authored
Jul 27, 2010
by
Andrew Gerrand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
net: add nil checks to several String methods to avoid panics
Fixes #945. R=r CC=golang-dev
https://golang.org/cl/1848049
parent
8b821696
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
27 additions
and
3 deletions
+27
-3
dnsclient.go
src/pkg/net/dnsclient.go
+3
-0
iprawsock.go
src/pkg/net/iprawsock.go
+6
-1
net.go
src/pkg/net/net.go
+6
-0
tcpsock.go
src/pkg/net/tcpsock.go
+6
-1
udpsock.go
src/pkg/net/udpsock.go
+6
-1
No files found.
src/pkg/net/dnsclient.go
View file @
fc4ba154
...
...
@@ -30,6 +30,9 @@ type DNSError struct {
}
func
(
e
*
DNSError
)
String
()
string
{
if
e
==
nil
{
return
"<nil>"
}
s
:=
"lookup "
+
e
.
Name
if
e
.
Server
!=
""
{
s
+=
" on "
+
e
.
Server
...
...
src/pkg/net/iprawsock.go
View file @
fc4ba154
...
...
@@ -30,7 +30,12 @@ type IPAddr struct {
// Network returns the address's network name, "ip".
func
(
a
*
IPAddr
)
Network
()
string
{
return
"ip"
}
func
(
a
*
IPAddr
)
String
()
string
{
return
a
.
IP
.
String
()
}
func
(
a
*
IPAddr
)
String
()
string
{
if
a
==
nil
{
return
"<nil>"
}
return
a
.
IP
.
String
()
}
func
(
a
*
IPAddr
)
family
()
int
{
if
a
==
nil
||
len
(
a
.
IP
)
<=
4
{
...
...
src/pkg/net/net.go
View file @
fc4ba154
...
...
@@ -129,6 +129,9 @@ type OpError struct {
}
func
(
e
*
OpError
)
String
()
string
{
if
e
==
nil
{
return
"<nil>"
}
s
:=
e
.
Op
if
e
.
Net
!=
""
{
s
+=
" "
+
e
.
Net
...
...
@@ -164,6 +167,9 @@ type AddrError struct {
}
func
(
e
*
AddrError
)
String
()
string
{
if
e
==
nil
{
return
"<nil>"
}
s
:=
e
.
Error
if
e
.
Addr
!=
""
{
s
+=
" "
+
e
.
Addr
...
...
src/pkg/net/tcpsock.go
View file @
fc4ba154
...
...
@@ -30,7 +30,12 @@ type TCPAddr struct {
// Network returns the address's network name, "tcp".
func
(
a
*
TCPAddr
)
Network
()
string
{
return
"tcp"
}
func
(
a
*
TCPAddr
)
String
()
string
{
return
joinHostPort
(
a
.
IP
.
String
(),
itoa
(
a
.
Port
))
}
func
(
a
*
TCPAddr
)
String
()
string
{
if
a
==
nil
{
return
"<nil>"
}
return
joinHostPort
(
a
.
IP
.
String
(),
itoa
(
a
.
Port
))
}
func
(
a
*
TCPAddr
)
family
()
int
{
if
a
==
nil
||
len
(
a
.
IP
)
<=
4
{
...
...
src/pkg/net/udpsock.go
View file @
fc4ba154
...
...
@@ -30,7 +30,12 @@ type UDPAddr struct {
// Network returns the address's network name, "udp".
func
(
a
*
UDPAddr
)
Network
()
string
{
return
"udp"
}
func
(
a
*
UDPAddr
)
String
()
string
{
return
joinHostPort
(
a
.
IP
.
String
(),
itoa
(
a
.
Port
))
}
func
(
a
*
UDPAddr
)
String
()
string
{
if
a
==
nil
{
return
"<nil>"
}
return
joinHostPort
(
a
.
IP
.
String
(),
itoa
(
a
.
Port
))
}
func
(
a
*
UDPAddr
)
family
()
int
{
if
a
==
nil
||
len
(
a
.
IP
)
<=
4
{
...
...
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