Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

plumbing: format/packfile, fix crash with cycle deltas#731

Merged
mcuadros merged 2 commits intosrc-d:masterfrom
jfontan:fix/crash-with-delta-cycles
Jan 25, 2018
Merged

plumbing: format/packfile, fix crash with cycle deltas#731
mcuadros merged 2 commits intosrc-d:masterfrom
jfontan:fix/crash-with-delta-cycles

Conversation

@jfontan
Copy link
Contributor

@jfontan jfontan commented Jan 24, 2018

Resolving cycles relied on ObjectToPack objects having Original. This is no longer true with the changes from #720. This commit changes:

  • Save original type, hash and size in ObjectToPack
  • Use SetObject to set both Original and resolved type, hash and size
  • Restore original object before using BackToOriginal (cycle resolution)
  • Update encoder test to check this case

Resolving cycles relied on ObjectToPack objects having Original. This
is no longer true with the changes from src-d#720. This commit changes:

* Save original type, hash and size in ObjectToPack
* Use SetObject to set both Original and resolved type, hash and size
* Restore original object before using BackToOriginal (cycle resolution)
* Update encoder test to check this case

Signed-off-by: Javi Fontan <jfontan@gmail.com>
@jfontan jfontan requested review from ajnavarro and mcuadros January 24, 2018 17:40
// SetOriginal sets both Original and saves size, type and hash
func (o *ObjectToPack) SetOriginal(obj plumbing.EncodedObject) {
o.Original = obj
o.originalSize = obj.Size()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check if obj is nil

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added checks to SetOriginal and BackToOriginal. The test now also uses it to set Original to nil.

SetOriginal now skips setting resolved values if the provided
object is nil. BackToOriginal also skips nil Original objects.

Signed-off-by: Javi Fontan <jfontan@gmail.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants