1899 {
1902 if( nNewBufSize < INT_MAX - nNewBufSize / 3 )
1903 nNewBufSize += nNewBufSize / 3;
1904 else
1905 nNewBufSize = INT_MAX;
1906
1907
1908
1909
1910 if( nNewBufSize >= 10 * 1024 * 1024 )
1911 {
1912 if( psSHP->nBufSize < 10 * 1024 * 1024 )
1913 {
1915 psSHP->sHooks.FSeek( psSHP->fpSHP, 0, 2 );
1916 nFileSize = psSHP->sHooks.FTell(psSHP->fpSHP);
1917 if( nFileSize >= UINT_MAX )
1918 psSHP->nFileSize = UINT_MAX;
1919 else
1920 psSHP->nFileSize =
STATIC_CAST(
unsigned int, nFileSize);
1921 }
1922
1923 if( psSHP->panRecOffset[hEntity] >= psSHP->nFileSize ||
1924
1925
1926
1927
1928 psSHP->panRecSize[hEntity] > psSHP->nFileSize - psSHP->panRecOffset[hEntity] )
1929 {
1931 snprintf(
str,
sizeof(
str),
1932 "Error in fread() reading object of size %d at offset %u from .shp file",
1934 str[
sizeof(
str)-1] =
'\0';
1935
1936 psSHP->sHooks.Error(
str );
1938 }
1939 }
1940
1943 {
1944 snprintf( szErrorMsg, sizeof(szErrorMsg),
1945 "Not enough memory to allocate requested memory (nNewBufSize=%d). "
1946 "Probably broken SHP file", nNewBufSize);
1947 szErrorMsg[sizeof(szErrorMsg)-1] = '\0';
1948 psSHP->sHooks.Error( szErrorMsg );
1950 }
1951
1952
1953 psSHP->pabyRec = pabyRecNew;
1954 psSHP->nBufSize = nNewBufSize;
1955 }
static void * SfRealloc(void *pMem, int nNewSize)
#define STATIC_CAST(type, x)