--===============2401118357134179939== MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://git.reviewboard.kde.org/r/129995/ ----------------------------------------------------------- (Updated March 8, 2017, 2:43 a.m.) Status ------ This change has been marked as submitted. Review request for Plasma, Aleix Pol Gonzalez and Kai Uwe Broulik. Changes ------- Submitted with commit 55237430bdab1bfbbfb442281ca5e34f5eb5e212 by Leslie Zhai to branch master. Repository: plasma-workspace Description ------- 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(); 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 Diffs ----- runners/kill/killrunner.cpp 5c2e8529 Diff: https://git.reviewboard.kde.org/r/129995/diff/ Testing ------- Thanks, Leslie Zhai --===============2401118357134179939== MIME-Version: 1.0 Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: 7bit
This is an automatically generated e-mail. To reply, visit: https://git.reviewboard.kde.org/r/129995/

This change has been marked as submitted.


Review request for Plasma, Aleix Pol Gonzalez and Kai Uwe Broulik.
By Leslie Zhai.

Updated March 8, 2017, 2:43 a.m.

Changes

Submitted with commit 55237430bdab1bfbbfb442281ca5e34f5eb5e212 by Leslie Zhai to branch master.
Repository: plasma-workspace

Description

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

Diffs

  • runners/kill/killrunner.cpp (5c2e8529)

View Diff

--===============2401118357134179939==--