Remove a local variable that was hiding the ec parameter and preventing error codes from being correctly propagated. Fixes #1820.