Closed GoogleCodeExporter closed 9 years ago
Even bigger patch, concerning not only memory leaks but null and undefined
behavior. Should have added handling numbers also, though.
333,334c333
< char ** params = (char **)malloc(nparams);
< size_t n = 0;
---
> char ** params = (char **)malloc(nparams * sizeof(char*));
336,339c335,343
< n = tarray->Get(JS_INT(i))->ToString()->Utf8Length();
< v8::String::Utf8Value tval(tarray->Get(JS_INT(i))->ToString());
< params[i] = new char[n + 1];
< params[i] = strdup(*tval);
---
> v8::Local<v8::Value> val=tarray->Get(JS_INT(i));
> if (val->IsUndefined()) {
> params[i]=NULL;
> } else if (val->IsNull()) {
> params[i]=NULL;
> } else {
> v8::String::Utf8Value tval(val->ToString());
> if (tval.length()) params[i] = strdup(*tval); else params[i]=NULL;
> }
341a346,350
>
> for(int i = 0; i < nparams; i++)
> if (params[i]) free(params[i]);
> free(params);
>
Original comment by vahv...@gmail.com
on 9 Dec 2010 at 3:54
Hi,
thanks a lot for patch - can you please add your diff as an attachment?
Original comment by ondrej.zara
on 9 Dec 2010 at 6:32
Fixed in r903.
Original comment by ondrej.zara
on 24 Jan 2011 at 10:58
Original issue reported on code.google.com by
vahv...@gmail.com
on 9 Dec 2010 at 3:30