Skip to main content
added 26 characters in body
Source Link
Roland Kofler
  • 11.7k
  • 3
  • 44
  • 83

If your code looks like this in pseudo code:

function do:
   if (pool has mymoney = true)
     split(mymoney) 
     pool has mymoney = false

By repeatedly calling that function, you have sort of a race condition where you are allowed to spend your money twice, trice, ... ad infitum.

Fix is simple, reverse two operations:

function do:
   if (pool has mymoney = true)
     pool= pool - mymoney // 2
     split(mymoney) //1
     

See this commit for example of the fix

If your code looks like this in pseudo code:

function do:
   if (pool has mymoney = true)
     split(mymoney)
     pool has mymoney = false

By repeatedly calling that function, you have sort of a race condition where you are allowed to spend your money twice, trice, ... ad infitum.

Fix is simple reverse:

function do:
   if (pool has mymoney = true)
     pool= pool - mymoney
     split(mymoney)
     

See this commit for example of the fix

If your code looks like this in pseudo code:

function do:
   if (pool has mymoney = true)
     split(mymoney) 
     pool has mymoney = false

By repeatedly calling that function, you have sort of a race condition where you are allowed to spend your money twice, trice, ... ad infitum.

Fix is simple, reverse two operations:

function do:
   if (pool has mymoney = true)
     pool= pool - mymoney // 2
     split(mymoney) //1
     

See this commit for example of the fix

Source Link
Roland Kofler
  • 11.7k
  • 3
  • 44
  • 83

If your code looks like this in pseudo code:

function do:
   if (pool has mymoney = true)
     split(mymoney)
     pool has mymoney = false

By repeatedly calling that function, you have sort of a race condition where you are allowed to spend your money twice, trice, ... ad infitum.

Fix is simple reverse:

function do:
   if (pool has mymoney = true)
     pool= pool - mymoney
     split(mymoney)
     

See this commit for example of the fix