Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix slice bounds out of range panic when stopping Tello drone #631

Merged
merged 1 commit into from Oct 11, 2018

Conversation

@eleniums
Copy link
Contributor

@eleniums eleniums commented Oct 9, 2018

Most of the time when stopping my DJI Tello drone, I was getting this panic:

panic: runtime error: slice bounds out of range

goroutine 50 [running]:
gobot.io/x/gobot/platforms/dji/tello.(*Driver).processVideo.func1(0xc4200d2000)
	/Users/snelson/go/src/gobot.io/x/gobot/platforms/dji/tello/driver.go:819 +0x24e
created by gobot.io/x/gobot/platforms/dji/tello.(*Driver).processVideo
	/Users/snelson/go/src/gobot.io/x/gobot/platforms/dji/tello/driver.go:815 +0xe3
exit status 2

I noticed the driver was trying to publish a VideoFrameEvent before checking for an error from the read UDP operation. This commit moves the error check to immediately after the read operation and continues if an error occurred. This avoids trying to slice an empty buffer and dodges a panic.

Signed-off-by: eleniums <eleniums@yahoo.com>
@codecov
Copy link

@codecov codecov bot commented Oct 9, 2018

Codecov Report

Merging #631 into dev will decrease coverage by <.01%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev     #631      +/-   ##
==========================================
- Coverage   77.73%   77.72%   -0.01%     
==========================================
  Files         157      157              
  Lines       10672    10673       +1     
==========================================
  Hits         8296     8296              
- Misses       1928     1929       +1     
  Partials      448      448
Impacted Files Coverage Δ
platforms/dji/tello/driver.go 25.65% <0%> (-0.07%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8f3b295...e23c01d. Read the comment docs.

@eleniums
Copy link
Contributor Author

@eleniums eleniums commented Oct 10, 2018

Do I need to increase code coverage in order for this pull request to be addressed and accepted?

@deadprogram
Copy link
Member

@deadprogram deadprogram commented Oct 11, 2018

Hi, @eleniums thank you very much for this PR. Test coverage would be nice, certainly, but the coverage in this platform is not very high to begin with. In any case, now merging, as I need this myself! Thanks again.

@deadprogram deadprogram merged commit d0f5ba5 into hybridgroup:dev Oct 11, 2018
2 of 4 checks passed
2 of 4 checks passed
@codecov
codecov/patch 0% of diff hit (target 77.73%)
Details
@codecov
codecov/project 77.72% (-0.01%) compared to 8f3b295
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@eleniums eleniums deleted the eleniums:fix/tello-read-udp-panic branch Oct 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants