Please tell us what command you're using, what options you're using, whether you have snap enabled, and how you arrived at the conclusion that the line's length is wrong.
If you specify a point near an object, and you have a relevant snap option turned on, the point you get will be the location you snapped to, not the location of the cursor. That might explain why you aren't getting the result you expect, especially since it's only happening near objects. You can see this process at work; AutoCAD will display a symbol at the snap point (which symbol depends on the type of snap).
You can test this hypothesis by turning off the object snap tool. There are several ways to do so: type OSNAP and clear the "Object Snap On" checkbox; press the F3 key; click on the Osnap toggle button on the status bar (if your status bar is visible). I can't find that command on the ribbon.