Fix cp crash when resuming from session (#2520)

We should make sure to handle errors properly
when reading from the session and also parsing.

Current master ignores all these situations
which leads to crash, this PR handles this to avoid
nil pointer crashes.
This commit is contained in:
Harshavardhana
2018-08-27 12:03:40 -07:00
committed by GitHub
parent bc679788ac
commit bc756e3dbd
+11 -1
View File
@@ -338,9 +338,19 @@ func doCopySession(session *sessionV8) error {
gracefulStop()
return
}
if e := urlScanner.Err(); e != nil {
// Error while reading. quit immediately
gracefulStop()
return
}
var cpURLs URLs
// Unmarshal copyURLs from each line.
json.Unmarshal([]byte(urlScanner.Text()), &cpURLs)
if e := json.Unmarshal([]byte(urlScanner.Text()), &cpURLs); e != nil {
errorIf(probe.NewError(e), "Unable to unmarshal %s", urlScanner.Text())
continue
}
// Save total count.
cpURLs.TotalCount = session.Header.TotalObjects