same patch but generated with:
git format-patch -1

I hope this is the right way to do it :-)

On Wed, Feb 10, 2010 at 4:25 PM, Felipe Sanches <[email protected]>wrote:

> hi, guys,
>
> The file attached to this bug report caught my attention to 2 bugs in our
> description of the dwg spec. The patch attached fixes these 2 bugs and thus
> results in the file being properly parsed by LibreDWG.
>
> As you can see in this part of the output I've got, all 14.778 objects of
> the dwg file were properly parsed, but now we have another issue: a segfault
> in the application itself (testSVG.c) instead of in the lib:
>
>
> Num objects: 14778
> ERROR: Decoding of DWG version R2004 header is not fully implemented yet.
> We are going to try
> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
> <svg
>    xmlns:svg="http://www.w3.org/2000/svg";
>    xmlns="http://www.w3.org/2000/svg";
>    xmlns:xlink="http://www.w3.org/1999/xlink";
>    version="1.1"
>    width="675557.074791"
>    height="287180.897189"
> >
>     <defs>
>
>
> Program received signal SIGSEGV, Segmentation fault.
> output_BLOCK_HEADER (ref=<value optimized out>) at testSVG.c:197
> 197      hdr = ref->obj->tio.object->tio.BLOCK_HEADER;
> (gdb)
>
>
>
> I am having some trouble with git recently.
> Pitanga, please apply this attached patch to your local copy and push it to
> git master
>
> Then I'll continue investigating what's causing this testSVG SegFault
>
> -Felipe
>
>
> <http://savannah.gnu.org/bugs/?28858>
>
>
From 4170f879a97f552cf917ffeb82aa0f24884970ce Mon Sep 17 00:00:00 2001
From: Felipe Correa da Silva Sanches <[email protected]>
Date: Wed, 10 Feb 2010 16:15:22 -0200
Subject: [PATCH] fix bugs in description of two objects of the spec: SORTENTSTABLE and LEADER were wrongly described

---
 src/decode.c |    7 +++++++
 src/dwg.h    |    4 ++--
 src/dwg.spec |    3 ++-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/decode.c b/src/decode.c
index 1b9b3b2..e9c2c6e 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -2169,6 +2169,13 @@ dwg_decode_handleref_with_code(Bit_Chain * dat, Dwg_Object * obj, Dwg_Data* dwg,
 {
   Dwg_Object_Ref * ref;
   ref = dwg_decode_handleref(dat, obj, dwg);
+
+  if (!ref)
+    {
+      LOG_ERROR("dwg_decode_handleref_with_code: ref is a null pointer\n");
+      return 0;
+    }
+
   if (ref->absolute_ref == 0 && ref->handleref.code != code)
     {
       LOG_ERROR("Expected a CODE %d handle, got a %d\n", code, ref->handleref.code)
diff --git a/src/dwg.h b/src/dwg.h
index 13f2b51..94413d3 100644
--- a/src/dwg.h
+++ b/src/dwg.h
@@ -1272,7 +1272,7 @@ typedef struct _dwg_entity_LEADER
   BITCODE_3DPOINT end_pt_proj;
   BITCODE_3DPOINT extrusion;
   BITCODE_3DPOINT x_direction;
-  BITCODE_3DPOINT offset_block_inspt;
+  BITCODE_3DPOINT offset_to_block_ins_pt;
   BITCODE_3DPOINT unknown_pt;
   BITCODE_BD dimgap;
   BITCODE_BD box_height;
@@ -2220,7 +2220,7 @@ typedef struct _dwg_object_RASTERVARIABLES
 typedef struct _dwg_object_SORTENTSTABLE
 {
   BITCODE_BL num_entries;
-  BITCODE_H sort_handle;
+  BITCODE_H* sort_handles;
   BITCODE_H parenthandle;
   BITCODE_H* reactors;
   BITCODE_H xdicobjhandle;
diff --git a/src/dwg.spec b/src/dwg.spec
index b2103d4..88b35a3 100644
--- a/src/dwg.spec
+++ b/src/dwg.spec
@@ -1465,6 +1465,7 @@ DWG_ENTITY(LEADER);
   FIELD_3DPOINT(end_pt_proj);
   FIELD_3DPOINT(extrusion);
   FIELD_3DPOINT(x_direction);
+  FIELD_3DPOINT(offset_to_block_ins_pt);
 
   SINCE(R_14)
     {
@@ -2702,7 +2703,7 @@ DWG_OBJECT_END
 DWG_OBJECT(SORTENTSTABLE);
 
   FIELD_BL (num_entries);
-  FIELD_HANDLE (sort_handle, 0);
+  HANDLE_VECTOR (sort_handles, num_entries, 0);
   FIELD_HANDLE (parenthandle, 4);
   REACTORS(4);
   XDICOBJHANDLE(3);
-- 
1.6.0.4

Reply via email to