## Affected version 

the latest commit: https://github.com/LibreDWG/libredwg/tree/45d2a290c65ed691be0901ba2b2ef51044e07a16 and 0.12.4

## What's the problem?


A double free was discovered in dwg_free_LAYER_private in dwg.spec.

ASAN report:

```
==3639890==ERROR: AddressSanitizer: attempting double-free on 0x602000009c70 in thread T0:
    #0 0x497ab2 in free /src/llvm-project-12.0.0.src/compiler-rt/lib/asan/asan_malloc_linux.cpp:127:3
    #1 0xd4b785 in dwg_free_LAYER_private /src/libredwg/src/./dwg.spec:2986:3
    #2 0xcd4248 in dwg_free_LAYER /src/libredwg/src/./dwg.spec:2948:1
    #3 0xd68ad9 in dwg_free_object /src/libredwg/src/free.c:759:7
    #4 0xd69575 in dwg_free /src/libredwg/src/free.c:1265:13
    #5 0x4c95e9 in main /src/libredwg/programs/dxf2dwg.c:412:11
    #6 0x7ffff7c580b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
    #7 0x41c40d in _start (/mnt/disk/out/libredwg/programs_asan/dxf2dwg+0x41c40d)

0x602000009c70 is located 0 bytes inside of 2-byte region [0x602000009c70,0x602000009c72)
freed by thread T0 here:
    #0 0x497ab2 in free /src/llvm-project-12.0.0.src/compiler-rt/lib/asan/asan_malloc_linux.cpp:127:3
    #1 0xd4b74a in dwg_free_LAYER_private /src/libredwg/src/./dwg.spec:2986:3
    #2 0xcd4248 in dwg_free_LAYER /src/libredwg/src/./dwg.spec:2948:1
    #3 0xd68ad9 in dwg_free_object /src/libredwg/src/free.c:759:7
    #4 0xd69575 in dwg_free /src/libredwg/src/free.c:1265:13
    #5 0x4c95e9 in main /src/libredwg/programs/dxf2dwg.c:412:11
    #6 0x7ffff7c580b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16

previously allocated by thread T0 here:
    #0 0x483614 in strdup /src/llvm-project-12.0.0.src/compiler-rt/lib/asan/asan_interceptors.cpp:437:3
    #1 0x1a92dd6 in new_object /src/libredwg/src/in_dxf.c:11750:44
    #2 0x1a73b0a in dxf_tables_read /src/libredwg/src/in_dxf.c:11909:22
    #3 0x1a6ce22 in dwg_read_dxf /src/libredwg/src/in_dxf.c:12779:23
    #4 0x4cb82a in dxf_read_file /src/libredwg/src/dwg.c:381:13
    #5 0x4c91c4 in main /src/libredwg/programs/dxf2dwg.c:312:15
    #6 0x7ffff7c580b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16

SUMMARY: AddressSanitizer: double-free /src/llvm-project-12.0.0.src/compiler-rt/lib/asan/asan_malloc_linux.cpp:127:3 in free
==3639890==ABORTING
```


## Compile command

```
CC="clang" CFLAGS="-O1 -g -fsanitize=address" ./configure --enable-release --disable-shared && make
```

## How can we reproduce the issue?

```
unzip tests_64266.zip
dxf2dwg ./tests_64266 -o /dev/null
```
POC file :  
[tests_64266.zip](https://github.com/LibreDWG/libredwg/files/6652554/tests_64266.zip)
Double free in function dwg_free_LAYER_private dwg.spec
This is a GitHub Issue
repo:libredwg
owner:LibreDWG
Title : Double free in function dwg_free_LAYER_private dwg.spec
Issue date:

--- start body ---
## Affected version 

the latest commit: https://github.com/LibreDWG/libredwg/tree/45d2a290c65ed691be0901ba2b2ef51044e07a16 and 0.12.4

## What's the problem?


A double free was discovered in dwg_free_LAYER_private in dwg.spec.

ASAN report:

```
==3639890==ERROR: AddressSanitizer: attempting double-free on 0x602000009c70 in thread T0:
    #0 0x497ab2 in free /src/llvm-project-12.0.0.src/compiler-rt/lib/asan/asan_malloc_linux.cpp:127:3
    #1 0xd4b785 in dwg_free_LAYER_private /src/libredwg/src/./dwg.spec:2986:3
    #2 0xcd4248 in dwg_free_LAYER /src/libredwg/src/./dwg.spec:2948:1
    #3 0xd68ad9 in dwg_free_object /src/libredwg/src/free.c:759:7
    #4 0xd69575 in dwg_free /src/libredwg/src/free.c:1265:13
    #5 0x4c95e9 in main /src/libredwg/programs/dxf2dwg.c:412:11
    #6 0x7ffff7c580b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
    #7 0x41c40d in _start (/mnt/disk/out/libredwg/programs_asan/dxf2dwg+0x41c40d)

0x602000009c70 is located 0 bytes inside of 2-byte region [0x602000009c70,0x602000009c72)
freed by thread T0 here:
    #0 0x497ab2 in free /src/llvm-project-12.0.0.src/compiler-rt/lib/asan/asan_malloc_linux.cpp:127:3
    #1 0xd4b74a in dwg_free_LAYER_private /src/libredwg/src/./dwg.spec:2986:3
    #2 0xcd4248 in dwg_free_LAYER /src/libredwg/src/./dwg.spec:2948:1
    #3 0xd68ad9 in dwg_free_object /src/libredwg/src/free.c:759:7
    #4 0xd69575 in dwg_free /src/libredwg/src/free.c:1265:13
    #5 0x4c95e9 in main /src/libredwg/programs/dxf2dwg.c:412:11
    #6 0x7ffff7c580b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16

previously allocated by thread T0 here:
    #0 0x483614 in strdup /src/llvm-project-12.0.0.src/compiler-rt/lib/asan/asan_interceptors.cpp:437:3
    #1 0x1a92dd6 in new_object /src/libredwg/src/in_dxf.c:11750:44
    #2 0x1a73b0a in dxf_tables_read /src/libredwg/src/in_dxf.c:11909:22
    #3 0x1a6ce22 in dwg_read_dxf /src/libredwg/src/in_dxf.c:12779:23
    #4 0x4cb82a in dxf_read_file /src/libredwg/src/dwg.c:381:13
    #5 0x4c91c4 in main /src/libredwg/programs/dxf2dwg.c:312:15
    #6 0x7ffff7c580b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16

SUMMARY: AddressSanitizer: double-free /src/llvm-project-12.0.0.src/compiler-rt/lib/asan/asan_malloc_linux.cpp:127:3 in free
==3639890==ABORTING
```


## Compile command

```
CC="clang" CFLAGS="-O1 -g -fsanitize=address" ./configure --enable-release --disable-shared && make
```

## How can we reproduce the issue?

```
unzip tests_64266.zip
dxf2dwg ./tests_64266 -o /dev/null
```
POC file :  
[tests_64266.zip](https://github.com/LibreDWG/libredwg/files/6652554/tests_64266.zip)
--- end body ---
