I've wrote a command line utility for extracting text from DXF files. My utility is named drawingtotext. Assuming a directory structure like this(Linux OS):
/home/dave/dxfs/
with a bunch of DXF files in the dxfs folder. From that location, assuming a file exists named "P1-1522-YI-WD-0403r1.dxf", running drawingtotext like this fails:
drawingtotext P1-1522-YI-WD-0403r1.dxf
with error: Segmentation fault (core dumped)
running drawingtotext ~/dxfs/P1-1522-YI-WD-0403r1.dxf
gives me what I expect plus this at the end:
*** Error in 'drawingtotext': free(): invalid next size (fast): 0x0000000002031170 ***
with a backtrace and huge memory map.
Now, moving that file up a directory (/home/dave/ instead of /home/dave/dxfs/) results in exactly the results I'm looking for with no error. Renaming the file to something else like "mydxf.dxf" and keeping it in /home/dave/dxfs/ fixes the issue as well.
My question is how and why does the location of the file change the behaviour of my program and how do I fix it?
The code is here: http://www.github.com/davidworkman9/drawingtotext/
the main file is called "AutoCADConverter.cpp"