@customize-agent/cad-native 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cad-native.c CHANGED
@@ -131,7 +131,14 @@ static void emit_entity_fields(FILE *out, Dwg_Object *obj, void *entity) {
131
131
  if (f->is_string || is_string_type(f->type)) {
132
132
  char *raw = NULL; int isnew = 0;
133
133
  if (dwg_dynapi_entity_utf8text(entity, obj->name, f->name, &raw, &isnew, NULL) && raw) pair_text(out, code, raw);
134
+ #ifndef _WIN32
135
+ /* isnew=1 means LibreDWG allocated the UTF-8 string with its own allocator.
136
+ * On Windows the sidecar links the official libredwg-0.dll (msvcrt heap),
137
+ * which is a different heap from this sidecar's CRT: freeing it here
138
+ * corrupts the heap (0xC0000374 / 0xC0000005). This process handles one
139
+ * DWG and exits, so the Windows build leaves library strings to the OS. */
134
140
  if (isnew && raw) free(raw);
141
+ #endif
135
142
  continue;
136
143
  }
137
144
  if (is_int_type(f->type)) {
@@ -240,14 +247,18 @@ static char *resolve_block_header_name(Dwg_Data *dwg, Dwg_Object_BLOCK_HEADER *h
240
247
  char *name = NULL; int isnew = 0;
241
248
  if (!dwg_dynapi_entity_utf8text(h, "BLOCK_HEADER", "name", &name, &isnew, NULL) || !name) return NULL;
242
249
  char *result = strdup(name);
243
- if (isnew) free(name);
250
+ #ifndef _WIN32
251
+ if (isnew) free(name); /* library-owned on Windows: see emit_entity_fields */
252
+ #endif
244
253
  if (result && result[0] == '*' && h->block_entity) {
245
254
  Dwg_Object *bl = h->block_entity->obj ? h->block_entity->obj : dwg_ref_object_silent(dwg, h->block_entity);
246
255
  if (bl && bl->fixedtype == DWG_TYPE_BLOCK && bl->tio.entity && bl->tio.entity->tio.BLOCK) {
247
256
  char *bn = NULL; int bnew = 0;
248
257
  if (dwg_dynapi_entity_utf8text(bl->tio.entity->tio.BLOCK, "BLOCK", "name", &bn, &bnew, NULL) && bn && *bn) {
249
258
  free(result); result = strdup(bn);
250
- if (bnew) free(bn);
259
+ #ifndef _WIN32
260
+ if (bnew) free(bn); /* library-owned on Windows: see emit_entity_fields */
261
+ #endif
251
262
  }
252
263
  }
253
264
  }
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@customize-agent/cad-native",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Prebuilt native DWG sidecar (LibreDWG 0.14) for customize-agent",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "engines": {