[Shapelib] Memory issue reading string field?

Brian Peschel brianp at occinc.com
Thu Aug 19 12:54:28 PDT 2010


  I have a simple DBF file I am trying to read:

dBase Reader and Converter V. 0.8, (c) 2002 - 2003 by Bjoern Berg

-- File statistics
dBase version.........:          FoxBase+/dBASE III+ (without memo)
Date of last update...:          1995-07-26
Number of records.....:          1414347 (001594cbd)
Length of header......:          97 (0061d)
Record length.........:          81 (0051d)
Columns in file.......:          2
Rows in file..........:          1414347

+---------------+-------+---------------+---------------+---------------+
| field name    | type  | field adress  | length        | field dec.    |
+---------------+-------+---------------+---------------+---------------+
|           ID  |   N   |        0      |  10           |   0           |
|       String  |   C   |        0      |  70           |   0           |
+---------------+-------+---------------+---------------+---------------+

I am seeing memory corruption in my program after reading this combo 
from the DBF.
          ID:    1374067
      String: UNITED STATES DEPARTMENT OF THE INTERIOR PATUXENT WILDLIFE 
RESEARCH CE
What makes this interesting is the string is 70 characters long (which 
is the width of the field).

If I change the string in the DBF to:
          ID:    1374067
      String: US DEPT OF THE INTERIOR PATUXENT WILDLIFE RESEARCH CENTER
(which is 57 characters) I no longer have any memory corruption.

I tries this on both 1.2.10 and 1.3.0b2.  Any ideas?

- B
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/shapelib/attachments/20100819/64d7d028/attachment.html>


More information about the Shapelib mailing list