<div dir="ltr">Thanks Even,<div><br></div><div>That solved the problem.</div><div><br></div><div>I've read the manual several times today but overlooked that the parameter should be a list.</div><div>Our code hasn't changed for years so this bug was unnoticed for a very long time ;)<br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><br>
Regards,</div><div dir="ltr"><br>Paul<br>
</div></div></div></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Op vr 4 feb. 2022 om 16:56 schreef Even Rouault <<a href="mailto:even.rouault@spatialys.com">even.rouault@spatialys.com</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  
    
  
  <div>
    <p>RTF(antastic)M :-)</p>
    <p>==>
<a href="https://gdal.org/doxygen/classOGRSpatialReference.html#af91af2639702e2793daf93ffe231b577" target="_blank">https://gdal.org/doxygen/classOGRSpatialReference.html#af91af2639702e2793daf93ffe231b577</a>
      :</p>
    <dl>
      <dt>Parameters</dt>
      <dd>
        <table>
          <tbody>
            <tr>
              <td>papszPrj</td>
              <td>NULL terminated list of strings containing the
                definition.</td>
            </tr>
          </tbody>
        </table>
      </dd>
    </dl>
    <div>So change your code to something like:</div>
    <div><br>
    </div>
    <div>  char apszPrj[2];<br>
        char* s = proj.GetBuffer();</div>
    <div>  apszPrj[0] = s;</div>
    <div>  apszPrj[1] = NULL;<br>
    </div>
    <div>  return sr->importFromWkt(apszPrj);</div>
    <div><br>
    </div>
    <div>Le 04/02/2022 à 16:47, Paul Meems a
      écrit :<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">
        <div>Hi List,</div>
        <div><br>
        </div>
        We use GDAL v3+ in our Open Source mapping application
        MapWinGIS.
        <div>We build using VS2019 on Windows and we use the files from
          GisInternals.</div>
        <div><br>
        </div>
        <div>We have a GeoProjection class which in turn calls
          some/most OGRSpatialReference methods.</div>
        <div>When calling OGRSpatialReference.importFromESRI() compiled
          for Win32 we have no issues.</div>
        <div>When calling the same code compiled for Win64 we get this
          exception:</div>
        <div>Exception thrown at 0x00007FFD93074839
          (gdal304.dll) 0xC0000005: Access violation reading location
          0xFFFFFFFFFFFFFFFF</div>
        <div><br>
        </div>
        <div>We also implement the very similar method importFromWkt().
          This method has no issues on Win32 or Win64.</div>
        <div><br>
        </div>
        <div>Here's some relevant code from GeoProjection.cpp:</div>
        <div>STDMETHODIMP CGeoProjection::ImportFromESRI(const BSTR
          proj, VARIANT_BOOL* retVal)<br>
          {<br>
            AFX_MANAGE_STATE(AfxGetStaticModuleState())<br>
            USES_CONVERSION;<br>
          <br>
            const CString s = OLE2A(proj);<br>
            const OGRErr err =
          ProjectionHelper::ImportFromEsri(_projection, s);<br>
          <br>
            *retVal = err == OGRERR_NONE ? VARIANT_TRUE : VARIANT_FALSE;<br>
            if (err != OGRERR_NONE)<br>
            {<br>
              ReportOgrError(err);<br>
            }<br>
            return S_OK;<br>
          }<br>
        </div>
        <div><br>
        </div>
        <div>STDMETHODIMP CGeoProjection::ImportFromWKT(const BSTR proj,
          VARIANT_BOOL* retVal)<br>
          {<br>
            AFX_MANAGE_STATE(AfxGetStaticModuleState())<br>
            USES_CONVERSION;<br>
          <br>
            const CString s = OLE2A(proj);<br>
            const OGRErr err =
          ProjectionHelper::ImportFromWkt(_projection, s);<br>
          <br>
            *retVal = err == OGRERR_NONE ? VARIANT_TRUE : VARIANT_FALSE;<br>
            if (err != OGRERR_NONE)<br>
            {<br>
              ReportOgrError(err);<br>
            }<br>
            return S_OK;<br>
          }<br>
          <div>
            <div dir="ltr">
              <div dir="ltr">
                <div>
                  <div dir="ltr">
                    <div dir="ltr">
                      <div dir="ltr">
                        <div dir="ltr"><br>
                        </div>
                        <div dir="ltr">And from ProjectionHelper.cpp:</div>
                        <div dir="ltr">OGRErr
                          ProjectionHelper::ImportFromEsri(OGRSpatialReference*
                          sr, CString proj)<br>
                          {<br>
                            if (!sr) {<br>
                              return false;<br>
                            }<br>
                          <br>
                            char* s = proj.GetBuffer();<br>
                            return sr->importFromESRI(&s);<br>
                          }</div>
                        <div dir="ltr"><br>
                        </div>
                        <div dir="ltr">OGRErr
                          ProjectionHelper::ImportFromWkt(OGRSpatialReference*
                          sr, CString proj)<br>
                          {<br>
                            if (!sr) {<br>
                              return false;<br>
                            }<br>
                          <br>
                            char* s = proj.GetBuffer();<br>
                            return sr->importFromWkt(&s);<br>
                          }<br>
                          <br>
                          We're currently upgrading from GDAL2+ to
                          GDAL3+.</div>
                        <div dir="ltr">Users report the crash in both
                          versions.</div>
                        <div dir="ltr"><br>
                        </div>
                        <div dir="ltr">Most likely we're not calling
                          the <span>importFromESRI</span> correctly.</div>
                        <div>Please advice.</div>
                        <div><br>
                        </div>
                        <div>Regards,</div>
                        <div dir="ltr"><br>
                          Paul Meems</div>
                        <div dir="ltr"><a href="https://github.com/MapWindow/MapWinGIS" target="_blank">https://github.com/MapWindow/MapWinGIS</a><br>
                        </div>
                        <div dir="ltr"><br>
                        </div>
                        <div dir="ltr"><br>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset></fieldset>
      <pre>_______________________________________________
gdal-dev mailing list
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">gdal-dev@lists.osgeo.org</a>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
    </blockquote>
    <pre cols="72">-- 
<a href="http://www.spatialys.com" target="_blank">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
  </div>

_______________________________________________<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="https://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a><br>
</blockquote></div>