Closed Bug 1283032 Opened 8 years ago Closed 8 years ago

[Static Analysis][Uninitialized pointer field] In constructor RunnableMethod

Categories

(Core :: IPC, defect, P1)

defect

Tracking

()

RESOLVED FIXED
mozilla50
Tracking Status
firefox50 --- fixed

People

(Reporter: andi, Assigned: andi)

References

(Blocks 1 open bug)

Details

(Keywords: coverity, Whiteboard: CID 1362753)

Attachments

(1 file)

The Static Analysis tool Coverity detected that member variables |obj_|, |meth_| and |params_| are not initialised in the default constructor. They are attributed values in the Init function that follows the constructor but though in order to integrate clang-plugin with uninitialised member checker we should move the initialisation in the constructor.
Comment on attachment 8766243 [details]
Bug 1283032 - initialize members from RunnableMethod in constructor.

https://reviewboard.mozilla.org/r/61216/#review58460

::: ipc/glue/TaskFactory.h:66
(Diff revision 1)
>    template <class Method>
>    inline already_AddRefed<Runnable> NewRunnableMethod(Method method) {
>      typedef TaskWrapper<RunnableMethod<Method, Tuple0> > TaskWrapper;
>  
> -    RefPtr<TaskWrapper> task = new TaskWrapper(this);
> -    task->Init(object_, method, base::MakeTuple());
> +    RefPtr<TaskWrapper> task = new TaskWrapper(this, object_, method,
> +      base::MakeTuple());

This should be indented to line up witht he opening paren on the previous line.

::: ipc/glue/TaskFactory.h:76
(Diff revision 1)
>    template <class Method, class A>
>    inline already_AddRefed<Runnable> NewRunnableMethod(Method method, const A& a) {
>      typedef TaskWrapper<RunnableMethod<Method, Tuple1<A> > > TaskWrapper;
>  
> -    RefPtr<TaskWrapper> task = new TaskWrapper(this);
> -    task->Init(object_, method, base::MakeTuple(a));
> +    RefPtr<TaskWrapper> task = new TaskWrapper(this, object_, method,
> +      base::MakeTuple(a));

Same here.

::: ipc/glue/TaskFactory.h:88
(Diff revision 1)
>    class RunnableMethod : public Runnable {
>     public:
> -    RunnableMethod() { }
> +    RunnableMethod(T* obj, Method meth, const Params& params)
> +      : obj_(obj)
> +      , meth_(meth)
> +      , params_(params){

There should be a space between the closing paren and the opening brace.
Attachment #8766243 - Flags: review?(wmccloskey) → review+
Comment on attachment 8766243 [details]
Bug 1283032 - initialize members from RunnableMethod in constructor.

Review request updated; see interdiff: https://reviewboard.mozilla.org/r/61216/diff/1-2/
Pushed by bpostelnicu@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/607b4d01aaee
initialize members from RunnableMethod in constructor. r=billm
https://hg.mozilla.org/mozilla-central/rev/607b4d01aaee
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla50
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: