|
@@ -124,6 +124,9 @@ impl<'info, T: ZeroCopy + Owner> AccountLoader<'info, T> {
|
|
|
.with_pubkeys((*acc_info.owner, T::owner())));
|
|
|
}
|
|
|
let data: &[u8] = &acc_info.try_borrow_data()?;
|
|
|
+ if data.len() < T::discriminator().len() {
|
|
|
+ return Err(ErrorCode::AccountDiscriminatorNotFound.into());
|
|
|
+ }
|
|
|
// Discriminator must match.
|
|
|
let disc_bytes = array_ref![data, 0, 8];
|
|
|
if disc_bytes != &T::discriminator() {
|
|
@@ -149,6 +152,9 @@ impl<'info, T: ZeroCopy + Owner> AccountLoader<'info, T> {
|
|
|
/// Returns a Ref to the account data structure for reading.
|
|
|
pub fn load(&self) -> Result<Ref<T>> {
|
|
|
let data = self.acc_info.try_borrow_data()?;
|
|
|
+ if data.len() < T::discriminator().len() {
|
|
|
+ return Err(ErrorCode::AccountDiscriminatorNotFound.into());
|
|
|
+ }
|
|
|
|
|
|
let disc_bytes = array_ref![data, 0, 8];
|
|
|
if disc_bytes != &T::discriminator() {
|
|
@@ -169,6 +175,9 @@ impl<'info, T: ZeroCopy + Owner> AccountLoader<'info, T> {
|
|
|
}
|
|
|
|
|
|
let data = self.acc_info.try_borrow_mut_data()?;
|
|
|
+ if data.len() < T::discriminator().len() {
|
|
|
+ return Err(ErrorCode::AccountDiscriminatorNotFound.into());
|
|
|
+ }
|
|
|
|
|
|
let disc_bytes = array_ref![data, 0, 8];
|
|
|
if disc_bytes != &T::discriminator() {
|