From b69e16a87681e8d1d50b2086e4b3e7e934325fd0 Mon Sep 17 00:00:00 2001 From: Greg Bray Date: Fri, 29 Jul 2016 13:28:01 -0600 Subject: [PATCH] vendor: fix memory leak in wmi and add float32 support Source: 771c736650b4aabf956d9103ba5bf439414f79f9 on github.com/stackexchange/wmi --- vendor/github.com/StackExchange/wmi/wmi.go | 18 +++++++++++++----- vendor/vendor.json | 4 ++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/vendor/github.com/StackExchange/wmi/wmi.go b/vendor/github.com/StackExchange/wmi/wmi.go index fc62377a96..c34c1d77c1 100644 --- a/vendor/github.com/StackExchange/wmi/wmi.go +++ b/vendor/github.com/StackExchange/wmi/wmi.go @@ -34,7 +34,6 @@ import ( "runtime" "strconv" "strings" - "sync" "time" "github.com/go-ole/go-ole" @@ -48,7 +47,6 @@ var ( // ErrNilCreateObject is the error returned if CreateObject returns nil even // if the error was nil. ErrNilCreateObject = errors.New("wmi: create object returned nil") - lock sync.Mutex ) // S_FALSE is returned by CoInitializeEx if it was already called on this thread. @@ -125,12 +123,10 @@ func (c *Client) Query(query string, dst interface{}, connectServerArgs ...inter return ErrInvalidEntityType } - lock.Lock() - defer lock.Unlock() runtime.LockOSThread() defer runtime.UnlockOSThread() - err := ole.CoInitializeEx(0, ole.COINIT_MULTITHREADED) + err := ole.CoInitializeEx(0, ole.COINIT_APARTMENTTHREADED) if err != nil { oleCode := err.(*ole.OleError).Code() if oleCode != ole.S_OK && oleCode != S_FALSE { @@ -187,6 +183,7 @@ func (c *Client) Query(query string, dst interface{}, connectServerArgs ...inter if enum == nil { return fmt.Errorf("can't get IEnumVARIANT, enum is nil") } + defer enum.Release() // Initialize a slice with Count capacity dv.Set(reflect.MakeSlice(dv.Type(), 0, int(count))) @@ -349,6 +346,17 @@ func (c *Client) loadEntity(dst interface{}, src *ole.IDispatch) (errFieldMismat Reason: "not a bool", } } + case float32: + switch f.Kind() { + case reflect.Float32: + f.SetFloat(float64(val)) + default: + return &ErrFieldMismatch{ + StructType: of.Type(), + FieldName: n, + Reason: "not a Float32", + } + } default: typeof := reflect.TypeOf(val) if typeof == nil && (isPtr || c.NonePtrZero) { diff --git a/vendor/vendor.json b/vendor/vendor.json index 474b5f077e..06391fedee 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -626,8 +626,8 @@ }, { "path": "github.com/stackexchange/wmi", - "revision": "d4ae5b448be53329ab38edcbc8aa1d196fc87f21", - "revisionTime": "2016-07-26T18:57:16-06:00" + "revision": "771c736650b4aabf956d9103ba5bf439414f79f9", + "revisionTime": "2016-07-24T15:06:07+02:00" }, { "path": "github.com/syndtr/goleveldb/leveldb",