From: Shenghou Ma Date: Wed, 7 Jan 2015 06:23:45 +0000 (-0500) Subject: misc/swig/stdio: fix broken nil pointer test X-Git-Tag: go1.5beta1~2410 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=583293349bccd62341f53941ccc68556563efd76;p=gostls13.git misc/swig/stdio: fix broken nil pointer test SWIG has always returned a typed interface value for a C++ class, so the interface value will never be nil even if the pointer itself is NULL. ptr == NULL in C/C++ should be ptr.Swigcptr() == 0 in Go. Fixes #9514. Change-Id: I3778b91acf54d2ff22d7427fbf2b6ec9b9ce3b43 Reviewed-on: https://go-review.googlesource.com/2440 Reviewed-by: Ian Lance Taylor --- diff --git a/misc/swig/stdio/file_test.go b/misc/swig/stdio/file_test.go index 6478a7cf37..38d0746768 100644 --- a/misc/swig/stdio/file_test.go +++ b/misc/swig/stdio/file_test.go @@ -10,7 +10,7 @@ import "testing" // as expected. func TestRead(t *testing.T) { f := Fopen("file_test.go", "r") - if f == nil { + if f.Swigcptr() == 0 { t.Fatal("fopen failed") } if Fgetc(f) != '/' || Fgetc(f) != '/' || Fgetc(f) != ' ' || Fgetc(f) != 'C' {