[PATCH:intel-gpu-tools] Move free(cmd) to after last use of cmd in intel_gpu_top
Alan Coopersmith
alan.coopersmith at oracle.com
Sat Feb 4 09:05:08 PST 2012
Error: Use after free (CWE 416)
Use after free of pointer 'cmd' in call to fprintf
at line 496 of tools/intel_gpu_top.c in function 'main'.
Previously freed at line 491 with free.
[ This bug was found by the Parfait 0.4.2 bug checking tool.
For more information see http://labs.oracle.com/projects/parfait/ ]
Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
tools/intel_gpu_top.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c
index bad4794..5a016c7 100644
--- a/tools/intel_gpu_top.c
+++ b/tools/intel_gpu_top.c
@@ -488,7 +488,6 @@ int main(int argc, char **argv)
else if (child_pid == 0) {
int res;
res = system(cmd);
- free(cmd);
if (res < 0)
perror("running command");
if (output) {
@@ -496,6 +495,7 @@ int main(int argc, char **argv)
fprintf(output, "# %s exited with status %d\n", cmd, res);
fflush(output);
}
+ free(cmd);
exit(0);
} else {
free(cmd);
--
1.7.3.2
More information about the xorg-devel
mailing list