Check nil returned

This commit is contained in:
Yasuhiro Matsumoto 2019-10-24 13:06:50 +09:00
parent 905d28af0e
commit 36ef426427
No known key found for this signature in database
GPG Key ID: 622DE34DC490584B

View File

@ -124,11 +124,12 @@ func (g *Graph) ImportWithOptions(def []byte, options GraphImportOptions) error
buf := C.TF_NewBuffer() buf := C.TF_NewBuffer()
defer C.TF_DeleteBuffer(buf) defer C.TF_DeleteBuffer(buf)
// Would have preferred to use C.CBytes, but that does not play well
// with "go vet" till https://github.com/golang/go/issues/17201 is
// resolved.
buf.length = C.size_t(len(def)) buf.length = C.size_t(len(def))
buf.data = C.CBytes(def) buf.data = C.CBytes(def)
if buf.data == nil {
return fmt.Errorf("unable to allocate memory")
}
defer C.free(buf.data)
status := newStatus() status := newStatus()