Check nil returned
This commit is contained in:
parent
905d28af0e
commit
36ef426427
@ -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()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user