소스 검색

Merge pull request #100 from Zariel/fix-unmarshal-null-uuid

When uunmarshalling uuid's, check if data is empty
Christoph Hack 12 년 전
부모
커밋
f590187bbc
1개의 변경된 파일5개의 추가작업 그리고 1개의 파일을 삭제
  1. 5 1
      marshal.go

+ 5 - 1
marshal.go

@@ -921,7 +921,7 @@ func marshalUUID(info *TypeInfo, value interface{}) ([]byte, error) {
 }
 
 func unmarshalUUID(info *TypeInfo, data []byte, value interface{}) error {
-	if data == nil {
+	if data == nil || len(data) == 0 {
 		switch v := value.(type) {
 		case *string:
 			*v = ""
@@ -932,11 +932,15 @@ func unmarshalUUID(info *TypeInfo, data []byte, value interface{}) error {
 		default:
 			return unmarshalErrorf("can not unmarshal X %s into %T", info, value)
 		}
+
+		return nil
 	}
+
 	u, err := UUIDFromBytes(data)
 	if err != nil {
 		return unmarshalErrorf("Unable to parse UUID: %s", err)
 	}
+
 	switch v := value.(type) {
 	case *string:
 		*v = u.String()