summaryrefslogtreecommitdiff
path: root/libgo/go/encoding/gob/encoder.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/encoding/gob/encoder.go')
-rw-r--r--libgo/go/encoding/gob/encoder.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/libgo/go/encoding/gob/encoder.go b/libgo/go/encoding/gob/encoder.go
index a340e47b5ed..62d0f42e81a 100644
--- a/libgo/go/encoding/gob/encoder.go
+++ b/libgo/go/encoding/gob/encoder.go
@@ -5,6 +5,7 @@
package gob
import (
+ "errors"
"io"
"reflect"
"sync"
@@ -65,6 +66,11 @@ func (enc *Encoder) writeMessage(w io.Writer, b *encBuffer) {
// it by hand.
message := b.Bytes()
messageLen := len(message) - maxLength
+ // Length cannot be bigger than the decoder can handle.
+ if messageLen >= tooBig {
+ enc.setError(errors.New("gob: encoder: message too big"))
+ return
+ }
// Encode the length.
enc.countState.b.Reset()
enc.countState.encodeUint(uint64(messageLen))