<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>RTF(antastic)M :-)</p>
    <p>==>
<a class="moz-txt-link-freetext" href="https://gdal.org/doxygen/classOGRSpatialReference.html#af91af2639702e2793daf93ffe231b577">https://gdal.org/doxygen/classOGRSpatialReference.html#af91af2639702e2793daf93ffe231b577</a>
      :</p>
    <dl class="params">
      <dt>Parameters</dt>
      <dd>
        <table class="params">
          <tbody>
            <tr>
              <td class="paramname">papszPrj</td>
              <td>NULL terminated list of strings containing the
                definition.</td>
            </tr>
          </tbody>
        </table>
      </dd>
    </dl>
    <div class="moz-cite-prefix">So change your code to something like:</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">  char apszPrj[2];<br>
        char* s = proj.GetBuffer();</div>
    <div class="moz-cite-prefix">  apszPrj[0] = s;</div>
    <div class="moz-cite-prefix">  apszPrj[1] = NULL;<br>
    </div>
    <div class="moz-cite-prefix">  return sr->importFromWkt(apszPrj);</div>
    <div class="moz-cite-prefix"><br>
    </div>
    <div class="moz-cite-prefix">Le 04/02/2022 à 16:47, Paul Meems a
      écrit :<br>
    </div>
    <blockquote type="cite"
cite="mid:CAHNf2YSnUz4=dMvKTfJi9Tot7NOpUn1EGJcD2aUtDMFSOE=90Q@mail.gmail.com">
      <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" class="gmail_signature"
              data-smartmail="gmail_signature">
              <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"
                            moz-do-not-send="true"
                            class="moz-txt-link-freetext">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 class="moz-mime-attachment-header"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
  </body>
</html>