CORIONplatform / solidity

GNU General Public License v3.0
12 stars 9 forks source link

modules.length++ does not do anything in addModule() in the base case in moduleHandler.sol, and modules[id] = input may not work as intended #82

Closed pyskell closed 7 years ago

pyskell commented 7 years ago

At the end of addModule() is the following code:

        if ( ! found ) {
            id = modules.length;
            modules.length++;
        }
        modules[id] = input;

modules.length++ will not increase the size of the array and is unnecessary.

According to this stackoverflow question you should likely be using modules.push() since modules does not have a declared size.

gundas commented 7 years ago

Actually the code works as expected:

  1. modules.length++ increases the size of the array as documented
  2. input is assigned to either the newly added last element of the array (in case not found) or to the found location in the array.