Skip to content

Commit f878ba6

Browse files
committed
add DEBUGGING_CLASS_CPP
and use it for TABLECONTENT. This is more stable than CLASS_DXF in cases when TABLE is mixed up with TABLECONTENT. See e.g. GH #178, where it fixes the heap_overflow2 case.
1 parent d2d72fc commit f878ba6

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

Diff for: src/classes.inc

+15-1
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@
5353
# define DEBUGGING_DXF(action, name) ALLOW_DXF(action, name)
5454
# define DEBUGGING_CLASS(action, name) UNSTABLE_CLASS(action, name)
5555
# define DEBUGGING_CLASS_DXF(action, name, _dxfname) UNSTABLE_CLASS_DXF(action, name, _dxfname)
56+
# define DEBUGGING_CLASS_CPP(action, name, cppname) UNSTABLE_CLASS_CPP(action, name, cppname)
5657
#else
5758
# define DEBUGGING_DXF(action, name) DISALLOW_DXF(action, name)
5859
# define DEBUGGING_CLASS(action, name) UNHANDLED_CLASS(action, name)
5960
# define DEBUGGING_CLASS_DXF(action, name, _dxfname) UNHANDLED_CLASS_DXF(action, name, _dxfname)
61+
# define DEBUGGING_CLASS_CPP(action, name, cppname) UNHANDLED_CLASS_CPP(action, name, cppname)
6062
#endif
6163

6264
//#define _DWG_FUNC_N(action,name) dwg_ ## action ## _ ## name
@@ -149,6 +151,18 @@
149151
/* return dwg_##action_##name(dat, obj); */ \
150152
return DWG_ERR_UNHANDLEDCLASS; \
151153
}
154+
#define UNHANDLED_CLASS_CPP(action, _name, _cppname) \
155+
if (klass->cppname && strEQc (klass->cppname, #_cppname)) \
156+
{ \
157+
WARN_UNHANDLED_CLASS; \
158+
if (strEQc (_STR(action), "decode") || !memcmp (_STR(action), "in", 2)) { \
159+
obj->name = (char*) #_name; \
160+
obj->dxfname = (char*) #_name; \
161+
obj->fixedtype = DWG_TYPE_##_name; \
162+
} \
163+
/* return dwg_##action_##name(dat, obj); */ \
164+
return DWG_ERR_UNHANDLEDCLASS; \
165+
}
152166

153167
/* Entities */
154168
STABLE_CLASS (ACTION, CAMERA) /*ent, not persistent in a DWG */
@@ -220,7 +234,7 @@
220234
DEBUGGING_CLASS (ACTION, SWEPTSURFACE) /*ent */
221235
DEBUGGING_CLASS_DXF (ACTION, TABLE, ACAD_TABLE) /*ent, r2010+ needs subclassing */
222236
DEBUGGING_CLASS (ACTION, ARC_DIMENSION) //ent
223-
DEBUGGING_CLASS (ACTION, TABLECONTENT) //wrong values
237+
DEBUGGING_CLASS_CPP (ACTION, TABLECONTENT, AcDbTableContent)
224238
DEBUGGING_CLASS (ACTION, TABLEGEOMETRY) //wrong geom_data
225239
DEBUGGING_CLASS (ACTION, CELLSTYLEMAP) //broken
226240
DEBUGGING_CLASS (ACTION, MATERIAL) //working on

Diff for: src/dec_macros.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1236,8 +1236,8 @@
12361236
obj_dat = *dat; \
12371237
hdl_dat = *dat; \
12381238
str_dat = *dat; \
1239-
error \
1240-
= dwg_decode_##token##_private (&obj_dat, &hdl_dat, &str_dat, obj); \
1239+
error = dwg_decode_##token##_private (&obj_dat, &hdl_dat, &str_dat, \
1240+
obj); \
12411241
} \
12421242
else { error = dwg_decode_##token##_private (dat, dat, dat, obj); } \
12431243
return error; \

0 commit comments

Comments
 (0)