Skip to content

Commit

Permalink
Fix storage bytes set-len when shrinking
Browse files Browse the repository at this point in the history
When the storage bytes has length 32, it loses data when setting the
length to a smaller value because it doesn't move the data correctly.
  • Loading branch information
gligneul committed Jan 27, 2025
1 parent c8e8818 commit a0c9eec
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion stylus-sdk/src/storage/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl StorageBytes {
}

// if shrinking, pull data in
if (len < 32) && (old > 32) {
if (len < 32) && (old >= 32) {
let word = Storage::get_word(self.__stylus_host.clone(), *self.base());
Storage::set_word(self.__stylus_host.clone(), self.root, word);
return self.write_len(len);
Expand Down

0 comments on commit a0c9eec

Please sign in to comment.