wc-duck / datalibrary

Open Source Data Library for data serialization.
Other
42 stars 8 forks source link

Crash. Packing strings. #7

Closed PerH closed 13 years ago

PerH commented 13 years ago

I have the following types:

"dl_material_mapping" : 
{
    "members" :
    [
        { "name" : "material", "type" : "string" },
        { "name" : "submesh", "type": "int8" }
    ]
},
"dl_model" : 
{
    "members" :
    [
        { "name" : "mesh", "type": "string" },
        { "name" : "materials", "type": "dl_material_mapping[]"}
    ]
}

Now when I pack the following data file dl_pack.exe crashes.

{
  "type": "dl_model",
  "data": {
    "mesh": "1234",
    "materials": [
      {
        "submesh": 2,
        "material": "apan.ymesjh"
      }
    ]
  }
}

If I change the line

"mesh": "meshname",

to

"mesh": "meshna",

it doesn't crash.

wc-duck commented 13 years ago

Issue should be fixed now. Alignment of subarrays might have been of. In this case a string would have been the last item written when packing text and making internal calculations of needed_size to be non-aligned. Later on, when writing array, dl would only seek to end and assume that alignment was correct