Skip to content

Commit 1a1e7fd

Browse files
committedMar 15, 2016
Merge pull request #39 from siddontang/fix-row-decode-panic
fix row decode panic
2 parents a1d80f5 + 5a32736 commit 1a1e7fd

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed
 

‎Makefile

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
ROOT_PATH=$(shell pwd)
2+
13
all: build
24

35
build:
4-
export GOBIN=./bin && \
6+
export GOBIN=${ROOT_PATH}/bin && \
57
godep go install ./...
68

79
test: build
8-
export GOBIN=./bin && \
10+
export GOBIN=${ROOT_PATH}/bin && \
911
godep go test ./...
1012

1113
clean:

‎replication/replication_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,8 @@ func (t *testSyncerSuite) TestMysqlBinlogCodec(c *C) {
260260
t.testSync(c, nil)
261261
}()
262262

263+
os.RemoveAll("./var")
264+
263265
err := t.b.StartBackup("./var", mysql.Position{"", uint32(0)}, 2*time.Second)
264266
c.Check(err, Equals, ErrGetEventTimeout)
265267

‎replication/row_event.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,13 @@ func (e *RowsEvent) Decode(data []byte) error {
257257
var err error
258258

259259
// ... repeat rows until event-end
260-
for pos < len(data) {
260+
// Why using pos < len(data) - 1 instead of origin pos < len(data) to check?
261+
// See mysql
262+
// https://github.com/mysql/mysql-server/blob/5.7/sql/log_event.cc#L9006
263+
// https://github.com/mysql/mysql-server/blob/5.7/sql/log_event.cc#L2492
264+
// A user panics here but he can't give me more information, and using len(data) - 1
265+
// fixes this panic, so I will try to construct a test case for this later.
266+
for pos < len(data)-1 {
261267
if n, err = e.decodeRows(data[pos:], e.Table, e.ColumnBitmap1); err != nil {
262268
return errors.Trace(err)
263269
}

0 commit comments

Comments
 (0)
Please sign in to comment.