setlocale returns a pointer that is no longer valid after the intermediate
call to setlocale.
pthread_mutex_lock( &self->mutex );
// Get the current locale
- const char *orig_localename = setlocale( LC_NUMERIC, NULL );
+ char *orig_localename = strdup( setlocale( LC_NUMERIC, NULL ) );
// Set the new locale
setlocale( LC_NUMERIC, localename );
}
// Restore the current locale
setlocale( LC_NUMERIC, orig_localename );
+ free( orig_localename );
pthread_mutex_unlock( &self->mutex );
}