Memory leak in InputVector.buffer
Submitted by Marcin Lewandowski
Link to original bug (#769224)
Description
Please consider the following piece of code:
class Test {
private void on_read(Socket socket) {
InputVector[] input_vectors = {
InputVector() {
buffer = new uint8[64],
size = 64
},
};
}
public static void main(string[] argv) {
}
}
valac 0.32.1 will produce the following piece of code
static void test_on_read (Test* self, GSocket* socket) {
GInputVector* input_vectors = NULL;
guint8* _tmp0_ = NULL;
GInputVector _tmp1_ = {0};
GInputVector* _tmp2_ = NULL;
gint input_vectors_length1 = 0;
gint _input_vectors_size_ = 0;
g_return_if_fail (self != NULL);
g_return_if_fail (socket != NULL);
_tmp0_ = g_new0 (guint8, 64);
memset (&_tmp1_, 0, sizeof (GInputVector));
_tmp1_.buffer = _tmp0_;
_tmp1_.size = (gsize) 64;
_tmp2_ = g_new0 (GInputVector, 1);
_tmp2_[0] = _tmp1_;
input_vectors = _tmp2_;
input_vectors_length1 = 1;
_input_vectors_size_ = input_vectors_length1;
input_vectors = (g_free (input_vectors), NULL);
}
tmp0 is never deallocated
probably the same apply to OutputVector
Version: 0.32.x
Edited by Corentin Noël