In hopes that this helps the next person to come to this post.
I believe the above post refers to C-Correction code written by Mort Canty for his book: Image Analysis, Classification and Change Detection in Remote Sensing, with Algorithms for ENVI/IDL and Python, Third revised edition. The code can be found here:
http://mortcanty.github.io/src/software.html
The C-Correction code (found in Chapter 5) does work, but will have errors and output NaN values if the DEM isn't larger than or exactly the same size as the image (or subset) you input into the algorithm. One way to avoid this is to make sure the DEM Raster is larger than your study area (the algorithm will automatically subset the DEM). Another solution is to subset your image based on the DEM coverage when you select your input image.
I've run the C-Correction code with ENVI 5.2 and can verify that it does work.