Imported Upstream version 4.8.1
[platform/upstream/gcc48.git] / libgo / go / net / rpc / jsonrpc / server.go
index 4c54553..5bc05fd 100644 (file)
@@ -12,6 +12,8 @@ import (
        "sync"
 )
 
+var errMissingParams = errors.New("jsonrpc: request body missing params")
+
 type serverCodec struct {
        dec *json.Decoder // for reading JSON values
        enc *json.Encoder // for writing JSON values
@@ -50,12 +52,8 @@ type serverRequest struct {
 
 func (r *serverRequest) reset() {
        r.Method = ""
-       if r.Params != nil {
-               *r.Params = (*r.Params)[0:0]
-       }
-       if r.Id != nil {
-               *r.Id = (*r.Id)[0:0]
-       }
+       r.Params = nil
+       r.Id = nil
 }
 
 type serverResponse struct {
@@ -88,6 +86,9 @@ func (c *serverCodec) ReadRequestBody(x interface{}) error {
        if x == nil {
                return nil
        }
+       if c.req.Params == nil {
+               return errMissingParams
+       }
        // JSON params is array value.
        // RPC params is struct.
        // Unmarshal into array containing struct for now.