1 | --- ext/fcgi/fcgi.c 2003-08-27 06:28:35.000000000 -0500 |
---|
2 | +++ ext/fcgi/fcgi.c.new 2005-03-22 09:34:55.000000000 -0600 |
---|
3 | @@ -37,6 +37,12 @@ |
---|
4 | rb_gc_mark(data->env); |
---|
5 | } |
---|
6 | |
---|
7 | +static void fcgi_free_req(fcgi_data *data) |
---|
8 | +{ |
---|
9 | + free(data->req); |
---|
10 | + free(data); |
---|
11 | +} |
---|
12 | + |
---|
13 | static VALUE fcgi_s_accept(VALUE self) |
---|
14 | { |
---|
15 | int status; |
---|
16 | @@ -64,7 +70,7 @@ |
---|
17 | VALUE obj,key, value; |
---|
18 | char *pkey,*pvalue; |
---|
19 | |
---|
20 | - obj = Data_Make_Struct(self, fcgi_data, fcgi_mark, 0, data); |
---|
21 | + obj = Data_Make_Struct(self, fcgi_data, fcgi_mark, fcgi_free_req, data); |
---|
22 | data->req = req; |
---|
23 | data->in = Data_Wrap_Struct(cFCGIStream, 0, 0, req->in); |
---|
24 | data->out = Data_Wrap_Struct(cFCGIStream, 0, 0, req->out); |
---|
25 | @@ -379,7 +385,10 @@ |
---|
26 | buff = ALLOC_N(char, 16384); |
---|
27 | n = FCGX_GetStr(buff, 16384, stream); |
---|
28 | CHECK_STREAM_ERROR(stream); |
---|
29 | - if (n == 0) return Qnil; |
---|
30 | + if (n == 0) { |
---|
31 | + free(buff); |
---|
32 | + return Qnil; |
---|
33 | + } |
---|
34 | str = rb_str_new(buff, n); |
---|
35 | OBJ_TAINT(str); |
---|
36 | |
---|
37 | @@ -389,9 +398,11 @@ |
---|
38 | if (n > 0) { |
---|
39 | rb_str_cat(str, buff, n); |
---|
40 | } else { |
---|
41 | + free(buff); |
---|
42 | return Qnil; |
---|
43 | } |
---|
44 | } |
---|
45 | + free(buff); |
---|
46 | return str; |
---|
47 | } |
---|
48 | |
---|
49 | @@ -404,9 +415,11 @@ |
---|
50 | if (n > 0) { |
---|
51 | str = rb_str_new(buff, n); |
---|
52 | OBJ_TAINT(str); |
---|
53 | + free(buff); |
---|
54 | return str; |
---|
55 | } |
---|
56 | else { |
---|
57 | + free(buff); |
---|
58 | return Qnil; |
---|
59 | } |
---|
60 | } |
---|