<div dir="ltr"><div>The only 'fix' I can get working is to return a zero-filled array if the call to VSIFReadL fails in IReadBlock. </div><div><br></div><div>Given that ReadBlock checks whether the block index is valid, I think it is safe to assume that if IReadBlock is called, the data is expected to be retrievable (i.e. VSIFReadL in IReadBlock would not fail due to a user requesting a block that is out of bounds as that raise an error much earlier), is it acceptable to do this?</div><div><br></div><div>Any reason for VSIFReadL to fail for a valid block index where an error would be preferable to a zero'd array?</div><div><br></div><div>I also tried to see whether VSIGetRangeStatusL could be of any help. Interestingly, for the newly created raster (without any data added), it returns <span style="color:rgb(0,0,0);font-family:Roboto,sans-serif;font-size:14px;line-height:22px">VSI_RANGE_STATUS_DATA for the very first block and </span><span style="color:rgb(0,0,0);font-family:Roboto,sans-serif;font-size:14px;line-height:22px">VSI_RANGE_STATUS_HOLE for subsequent blocks.</span></div><div><span style="color:rgb(0,0,0);font-family:Roboto,sans-serif;font-size:14px;line-height:22px"><br></span></div><div><br></div><div><br></div><div> </div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 14 July 2016 at 13:26, Even Rouault <span dir="ltr"><<a href="mailto:even.rouault@spatialys.com" target="_blank">even.rouault@spatialys.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Le jeudi 14 juillet 2016 13:07:42, jramm a écrit :<br>
> I added the following to the end of the Create method in<br>
> frmts/northwood/grddataset.cpp:<br>
><br>
><br>
>     vsi_l_offset nFileSize = 1024 + nXSize * nYSize * 2;<br>
<br>
</span>--> beware of the potential int32 overflow in nXSize * nYSize<br>
<span class=""><br>
>     if (VSIFTruncateL(poDS->fp, nFileSize) != 0) {<br>
>               CPLError(CE_Failure, CPLE_FileIO,<br>
>                               "Failed to allocate space for GRD file");<br>
>               delete poDS;<br>
>               return NULL;<br>
>     }<br>
>     poDS->FlushCache(); // Write the header to disk.<br>
><br>
> Unfortunately still receiving the error. I wonder if it would be better if<br>
> I explicitly write the zeros with VSIFWriteL?<br>
<br>
</span>No, that's what VSIFTruncateL() is supposed to do, in a smarter way depending<br>
on filesystem capabilities.<br>
<span class=""><br>
><br>
><br>
><br>
><br>
> --<br>
> View this message in context:<br>
> <a href="http://osgeo-org.1560.x6.nabble.com/Error-in-GDALWarp-to-NWT-GRD-tp5276136" rel="noreferrer" target="_blank">http://osgeo-org.1560.x6.nabble.com/Error-in-GDALWarp-to-NWT-GRD-tp5276136</a><br>
</span>> p5276347.html Sent from the GDAL - Dev mailing list archive at Nabble.com.<br>
<span class="im HOEnZb">> _______________________________________________<br>
> gdal-dev mailing list<br>
> <a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
> <a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="noreferrer" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
<br>
</span><div class="HOEnZb"><div class="h5">--<br>
Spatialys - Geospatial professional services<br>
<a href="http://www.spatialys.com" rel="noreferrer" target="_blank">http://www.spatialys.com</a><br>
</div></div></blockquote></div><br></div>