Geoff,

Thank you for quick action! My apologies - I should have sent the full
code instead of just diff, I think the diff was confusing a bit, as it
was from the stable 2.2.3 release and not from the latest svn snapshot.

So, I checked the new revision, one correction (and one question):
Method OBLocale::RestoreLocale() - my idea was to have  only "free()"
thrown out on Android because d->old_locale_string is a static string.

my version:

void OBLocale::RestoreLocale()
  {
    --d->counter;
    if(d->counter == 0) {
      // return the locale to the original one
#ifdef HAVE_USELOCALE
      uselocale(d->old_locale);
#else
      setlocale(LC_NUMERIC, d->old_locale_string);
#ifndef ANDROID
      free (d->old_locale_string);
#endif
#endif
    } 
  }   

----------------------------------
version from OB r4051:

 void OBLocale::RestoreLocale()
  {
    --d->counter;
    if(d->counter == 0) {
      // return the locale to the original one
#ifdef HAVE_USELOCALE
      uselocale(d->old_locale);
#else
#ifndef ANDROID
      setlocale(LC_NUMERIC, d->old_locale_string);
#endif
      free (d->old_locale_string);
#endif
    }
  }

That is, setlocale gets thrown out for Android, but "free" stays - which
doesn't really make sense to me.

Now for the question - is it valid to assign static character string
such as "C" to old_locale_string in SetLocale()? It's working for me,
but after some thinking I got to wonder if the stack for SetLocale()
might not get freed along with the location to which old_locale_string
is pointing and the later RestoreLocale() will therefore restore some
nonsensical locale value? Can somebody comment on this?

Best regards,
Igor

On Wed, 2010-09-15 at 20:59 -0400, Geoffrey Hutchison wrote:
> > so OBLocale::SetLocale() was segfaulting there. The following change
> > while not too elegant has solved the problem for me, is it too late to
> > request its inclusion into 2.3.0 release?
> 
> No, I think this would be the perfect time. It clearly only affects Android 
> and if you say it solves a segfault, that makes for a useful bugfix.
> 
> I had to apply by hand, so you may see a conflict. It's SVN r4050.
> 
> -Geoff
> 



------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
OpenBabel-Devel mailing list
OpenBabel-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openbabel-devel

Reply via email to