Fix KillRunner Memory leak

Review Request #129995 - Created March 7, 2017 and submitted

Information
Leslie Zhai
plasma-workspace
master
Reviewers
plasma
apol, broulik

Hi KDE developers,

Bug reported by the clang static analyzer.

Description: Potential leak of memory pointed to by 'process'
File: plasma-workspace/runners/kill/killrunner.cpp
Line: 186

168 void KillRunner::run(const Plasma::RunnerContext &context, const Plasma::QueryMatch &match)
169 {
170     Q_UNUSED(context)
171  
172     QVariantList data = match.data().value<QVariantList>();
173     quint64 pid = data[0].toUInt();
174 //     QString user = data[1].toString();
175  
176     int signal;
177     if (match.selectedAction() != NULL) {

Assuming the condition is false 
?

?
Taking false branch 
?
178         signal = match.selectedAction()->data().toInt();
179     } else {
180         signal = 9; //default: SIGKILL
181     }
182  
183     QStringList args;
184     args << QStringLiteral("-%1").arg(signal) << QStringLiteral("%1").arg(pid);
185     KProcess *process = new KProcess(this);

?
Memory is allocated 
?
186     int returnCode = process->execute(QStringLiteral("kill"), args);

?
Within the expansion of the macro 'QStringLiteral':
a
Potential leak of memory pointed to by 'process'

187  
188     if (returnCode == 0)

So I simply add delete process to free the allocated memory.

Regards,
Leslie Zhai


  

Issues

  • 0
  • 1
  • 0
  • 1
Description From Last Updated
David Edmundson
Leslie Zhai
Leslie Zhai
Review request changed

Status: Closed (submitted)

Change Summary:

Submitted with commit 55237430bdab1bfbbfb442281ca5e34f5eb5e212 by Leslie Zhai to branch master.
Loading...