[Vala] Serious regression on i18ned string



Version: 0.11.5 (The bug didn't appear in 0.9.2)

The following program crashes because it
tries to free a static string.

        struct Foo {
            public string foo;
            public string bar;
        }
        
        void main() {
           Foo f = Foo() {foo = "foo", bar = N_("bar")};
        }


In the generated C, Foo is destroyed like this:

        void foo_destroy (Foo* self) {
        	_g_free0 (self->foo);   <--- note this
        	_g_free0 (self->bar);   <--- and this
        }

However, foo and bar are not created equal:

        void buggy (void) {
        	gchar* _tmp0_;
        	Foo _tmp1_ = {0};
        	Foo _tmp2_ = {0};
        	Foo f;
        	_tmp0_ = g_strdup ("foo");       <--- works with _g_free0
        	memset (&_tmp1_, 0, sizeof (Foo));
        	_tmp1_.foo = _tmp0_;
        	_tmp1_.bar = "bar";              <--- _g_free0_ fails
        	_tmp2_ = _tmp1_;
        	f = _tmp2_;
        	foo_destroy (&f);
        }

Is this a known regression?

Nice day
Nor Jaidi Tuah




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]