Joaquim,<br><br>You did change pszSrcWkt (<a href="http://code.google.com/p/mirone/source/browse/trunk/mex/gdalwarp_mex.cpp#385">http://code.google.com/p/mirone/source/browse/trunk/mex/gdalwarp_mex.cpp#385</a>).<br><br>You should remove line 385 and move the line 386 to 330.<br>
<br><div class="gmail_quote">On Sat, Jan 23, 2010 at 11:17 PM,  <span dir="ltr">&lt;<a href="mailto:jluis@ualg.pt">jluis@ualg.pt</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">Quoting Even Rouault &lt;<a href="mailto:even.rouault@mines-paris.org" target="_blank">even.rouault@mines-paris.org</a>&gt;:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Joaquim,<br>
<br>
you don&#39;t provide enough code to really see what&#39;s wrong, but my guess is that you misuse GDAL API.<br>
</blockquote>
<br></div><div class="im">
Even<br>
<br>
Quite possible the first and I was trying to summarize what happens<br>
<br>
<br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br><div class="im">
If you get pszSrcWKT, with<br>
<br>
pszSrcWKT = GDALGetProjectionRef(hDS);<br>
</div></blockquote>
<br><div class="im">
<br>
No, I got it from oSrcSRS.exportToWkt( &amp;pszSrcWKT );<br>
<br>
See lines 325 &amp; 329 of<br>
<br>
<a href="http://code.google.com/p/mirone/source/browse/trunk/mex/gdalwarp_mex.cpp" target="_blank">code.google.com/p/mirone/source/browse/trunk/mex/gdalwarp_mex.cpp</a><br>
<br>
Joaquim<br>
<br>
<br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br><div><div></div><div class="h5">
The pszSrcWKT string is owned by the hDS object, so as soon as you destroy the hDS object with GDALClose(), the pointer becomes invalid and points to arbitrary data.<br>
<br>
For the same reason, you should never free the string returned by GDALGetProjectionRef() with OGRFree() or any other free() call.<br>
<br>
See <a href="http://gdal.org/classGDALDataset.html" target="_blank">http://gdal.org/classGDALDataset.html</a> :<br>
<br>
GDALDataset::GetProjectionRef() :<br>
<br>
returns:<br>
a pointer to an internal reference string. It should not be altered, freed or expected to last for long.<br>
<br>
Best regards,<br>
<br>
Even<br>
<br>
Le Saturday 23 January 2010 16:04:58 <a href="mailto:jluis@ualg.pt" target="_blank">jluis@ualg.pt</a>, vous avez écrit :<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br>
<br>
I have a serious crash in one of my Matlab MEXs caused by a call to<br>
OGRFree() with an argument of size one (possibly the  null terminator).<br>
This happens on OSX SL (64 bits) but not on Windows (where I still<br>
build at 32 bits)<br>
<br>
Here is, as far as I could trace it, what is happening (SVN version of<br>
the same age as GDAL1.7RC1)<br>
<br>
mexPrintf(&quot;---- %s\n%s\n&quot;, pszSrcWKT,pszDstWKT);<br>
<br>
That prints<br>
<br>
---- GEOGCS[&quot;WGS 84&quot;,DATUM[&quot;WGS_1984&quot;,SPHEROID[&quot;WGS<br>
84&quot;,6378137,298.257223563,AUTHORITY[&quot;EPSG&quot;,&quot;7030&quot;]],TOWGS84[0,0,0,0,0,0,0],<br>
AUTHORITY[&quot;EPSG&quot;,&quot;6326&quot;]],PRIMEM[&quot;Greenwich&quot;,0,AUTHORITY[&quot;EPSG&quot;,&quot;8901&quot;]],UNI<br>
T[&quot;degree&quot;,0.0174532925199433,AUTHORITY[&quot;EPSG&quot;,&quot;9108&quot;]],AUTHORITY[&quot;EPSG&quot;,&quot;43<br>
26&quot;]] PROJCS[&quot;UTM Zone 29, Northern Hemisphere&quot;,GEOGCS[&quot;WGS<br>
84&quot;,DATUM[&quot;WGS_1984&quot;,SPHEROID[&quot;WGS<br>
84&quot;,6378137,298.257223563,AUTHORITY[&quot;EPSG&quot;,&quot;7030&quot;]],TOWGS84[0,0,0,0,0,0,0],<br>
AUTHORITY[&quot;EPSG&quot;,&quot;6326&quot;]],PRIMEM[&quot;Greenwich&quot;,0,AUTHORITY[&quot;EPSG&quot;,&quot;8901&quot;]],UNI<br>
T[&quot;degree&quot;,0.0174532925199433,AUTHORITY[&quot;EPSG&quot;,&quot;9108&quot;]],AUTHORITY[&quot;EPSG&quot;,&quot;43<br>
26&quot;]],PROJECTION[&quot;Transverse_Mercator&quot;],PARAMETER[&quot;latitude_of_origin&quot;,0],PA<br>
RAMETER[&quot;central_meridian&quot;,-9],PARAMETER[&quot;scale_factor&quot;,0.9996],PARAMETER[&quot;f<br>
alse_easting&quot;,500000],PARAMETER[&quot;false_northing&quot;,0],UNIT[&quot;Meter&quot;,1]]<br>
<br>
<br>
Next the code does:<br>
<br>
        GDALClose( hSrcDS );<br>
mexPrintf(&quot;---- %s\n%s\n&quot;, pszSrcWKT,pszDstWKT);<br>
<br>
and now pszSrcWKT is empty. See<br>
<br>
---- PROJCS[&quot;UTM Zone 29, Northern Hemisphere&quot;,GEOGCS[&quot;WGS<br>
84&quot;,DATUM[&quot;WGS_1984&quot;,SPHEROID[&quot;WGS<br>
84&quot;,6378137,298.257223563,AUTHORITY[&quot;EPSG&quot;,&quot;7030&quot;]],TOWGS84[0,0,0,0,0,0,0],<br>
AUTHORITY[&quot;EPSG&quot;,&quot;6326&quot;]],PRIMEM[&quot;Greenwich&quot;,0,AUTHORITY[&quot;EPSG&quot;,&quot;8901&quot;]],UNI<br>
T[&quot;degree&quot;,0.0174532925199433,AUTHORITY[&quot;EPSG&quot;,&quot;9108&quot;]],AUTHORITY[&quot;EPSG&quot;,&quot;43<br>
26&quot;]],PROJECTION[&quot;Transverse_Mercator&quot;],PARAMETER[&quot;latitude_of_origin&quot;,0],PA<br>
RAMETER[&quot;central_meridian&quot;,-9],PARAMETER[&quot;scale_factor&quot;,0.9996],PARAMETER[&quot;f<br>
alse_easting&quot;,500000],PARAMETER[&quot;false_northing&quot;,0],UNIT[&quot;Meter&quot;,1]]<br>
<br>
If I make it print the size of pszSrcWKT  with strlen(pszSrcWKT) the<br>
answer is 1 and finally the MEX (and the entire MATLAB) crash on the<br>
call<br>
<br>
OGRFree(pszSrcWKT);<br>
<br>
<br>
Joaquim Luis<br>
<br>
----------------------------------------------------------------<br>
This message was sent using IMP, the Internet Messaging Program.<br>
<br>
_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
</blockquote>
<br>
<br>
<br>
</div></div></blockquote><div><div></div><div class="h5">
<br>
<br>
<br>
----------------------------------------------------------------<br>
This message was sent using IMP, the Internet Messaging Program.<br>
<br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Best regards,<br>Chaitanya kumar CH.<br>/tʃaɪθənjə/ /kʊmɑr/ <br>+91-9848167848<br>17.241582N 80.142635E<br>