Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ incremented for features.

## [Unreleased]

### Features

* lang: Check that ProgramAccount writable before mut borrow ([#681](https://github.com/project-serum/anchor/pull/681)).

## [0.14.0] - 2021-09-02

### Features
Expand Down
6 changes: 6 additions & 0 deletions lang/src/program_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::{
use solana_program::account_info::AccountInfo;
use solana_program::entrypoint::ProgramResult;
use solana_program::instruction::AccountMeta;
use solana_program::msg;
use solana_program::program_error::ProgramError;
use solana_program::pubkey::Pubkey;
use std::ops::{Deref, DerefMut};
Expand Down Expand Up @@ -156,6 +157,11 @@ impl<'a, T: AccountSerialize + AccountDeserialize + Clone> Deref for ProgramAcco

impl<'a, T: AccountSerialize + AccountDeserialize + Clone> DerefMut for ProgramAccount<'a, T> {
fn deref_mut(&mut self) -> &mut Self::Target {
if !self.inner.info.is_writable {
Comment thread
fanatid marked this conversation as resolved.
msg!("The given ProgramAccount is not mutable");
panic!();
}

&mut DerefMut::deref_mut(&mut self.inner).account
}
}
Expand Down