1910 {
1913 if( nNewBufSize < INT_MAX - nNewBufSize / 3 )
1914 nNewBufSize += nNewBufSize / 3;
1915 else
1916 nNewBufSize = INT_MAX;
1917
1918
1919
1920
1921 if( nNewBufSize >= 10 * 1024 * 1024 )
1922 {
1923 if( psSHP->nBufSize < 10 * 1024 * 1024 )
1924 {
1926 psSHP->sHooks.FSeek( psSHP->fpSHP, 0, 2 );
1927 nFileSize = psSHP->sHooks.FTell(psSHP->fpSHP);
1928 if( nFileSize >= UINT_MAX )
1929 psSHP->nFileSize = UINT_MAX;
1930 else
1931 psSHP->nFileSize =
STATIC_CAST(
unsigned int, nFileSize);
1932 }
1933
1934 if( psSHP->panRecOffset[hEntity] >= psSHP->nFileSize ||
1935
1936
1937
1938
1939 psSHP->panRecSize[hEntity] > psSHP->nFileSize - psSHP->panRecOffset[hEntity] )
1940 {
1942 snprintf(
str,
sizeof(
str),
1943 "Error in fread() reading object of size %d at offset %u from .shp file",
1945 str[
sizeof(
str)-1] =
'\0';
1946
1947 psSHP->sHooks.Error(
str );
1949 }
1950 }
1951
1954 {
1955 snprintf( szErrorMsg, sizeof(szErrorMsg),
1956 "Not enough memory to allocate requested memory (nNewBufSize=%d). "
1957 "Probably broken SHP file", nNewBufSize);
1958 szErrorMsg[sizeof(szErrorMsg)-1] = '\0';
1959 psSHP->sHooks.Error( szErrorMsg );
1961 }
1962
1963
1964 psSHP->pabyRec = pabyRecNew;
1965 psSHP->nBufSize = nNewBufSize;
1966 }
static void * SfRealloc(void *pMem, int nNewSize)
#define STATIC_CAST(type, x)