qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] cmd: Fix potential NULL pointer dereference
@ 2011-10-28 21:48 Pavel Borzenkov
  2011-10-31  6:27 ` Markus Armbruster
  0 siblings, 1 reply; 3+ messages in thread
From: Pavel Borzenkov @ 2011-10-28 21:48 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial

Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com>
---
Note, that almost all code in the file violates CODING STYLE. The changed lines
are written wrt CODING STYLE (like commits 7d7d975c and c32d766a).
---

 cmd.c |   11 +++--------
 1 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/cmd.c b/cmd.c
index f77897e..abcf206 100644
--- a/cmd.c
+++ b/cmd.c
@@ -49,7 +49,7 @@ void
 add_command(
 	const cmdinfo_t	*ci)
 {
-	cmdtab = realloc((void *)cmdtab, ++ncmds * sizeof(*cmdtab));
+    cmdtab = g_realloc((void *)cmdtab, ++ncmds * sizeof(*cmdtab));
 	cmdtab[ncmds - 1] = *ci;
 	qsort(cmdtab, ncmds, sizeof(*cmdtab), compare);
 }
@@ -125,12 +125,7 @@ find_command(
 void
 add_user_command(char *optarg)
 {
-	ncmdline++;
-	cmdline = realloc(cmdline, sizeof(char*) * (ncmdline));
-	if (!cmdline) {
-		perror("realloc");
-		exit(1);
-	}
+    cmdline = g_realloc(cmdline, ++ncmdline * sizeof(char *));
 	cmdline[ncmdline-1] = optarg;
 }
 
@@ -194,7 +189,7 @@ command_loop(void)
 		doneline(input, v);
 	}
 	if (cmdline) {
-		free(cmdline);
+        g_free(cmdline);
 		return;
 	}
 
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] cmd: Fix potential NULL pointer dereference
  2011-10-28 21:48 [Qemu-devel] [PATCH] cmd: Fix potential NULL pointer dereference Pavel Borzenkov
@ 2011-10-31  6:27 ` Markus Armbruster
  2011-10-31  7:18   ` Pavel Borzenkov
  0 siblings, 1 reply; 3+ messages in thread
From: Markus Armbruster @ 2011-10-31  6:27 UTC (permalink / raw)
  To: Pavel Borzenkov; +Cc: qemu-trivial, qemu-devel

Pavel Borzenkov <pavel.borzenkov@gmail.com> writes:

> Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com>
> ---
> Note, that almost all code in the file violates CODING STYLE. The changed lines
> are written wrt CODING STYLE (like commits 7d7d975c and c32d766a).
>
> ---
>
>  cmd.c |   11 +++--------
>  1 files changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/cmd.c b/cmd.c
> index f77897e..abcf206 100644
> --- a/cmd.c
> +++ b/cmd.c
> @@ -49,7 +49,7 @@ void
>  add_command(
>  	const cmdinfo_t	*ci)
>  {
> -	cmdtab = realloc((void *)cmdtab, ++ncmds * sizeof(*cmdtab));
> +    cmdtab = g_realloc((void *)cmdtab, ++ncmds * sizeof(*cmdtab));
>  	cmdtab[ncmds - 1] = *ci;
>  	qsort(cmdtab, ncmds, sizeof(*cmdtab), compare);
>  }

Inconsistent indentation.

Either stick to the original indentation, or reindent the whole
function.

[More of the same...]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] cmd: Fix potential NULL pointer dereference
  2011-10-31  6:27 ` Markus Armbruster
@ 2011-10-31  7:18   ` Pavel Borzenkov
  0 siblings, 0 replies; 3+ messages in thread
From: Pavel Borzenkov @ 2011-10-31  7:18 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: qemu-trivial, qemu-devel

On Mon, Oct 31, 2011 at 10:27 AM, Markus Armbruster <armbru@redhat.com> wrote:
> Pavel Borzenkov <pavel.borzenkov@gmail.com> writes:
>
>> Signed-off-by: Pavel Borzenkov <pavel.borzenkov@gmail.com>
>> ---
>> Note, that almost all code in the file violates CODING STYLE. The changed lines
>> are written wrt CODING STYLE (like commits 7d7d975c and c32d766a).
>>
>> ---
>>
>>  cmd.c |   11 +++--------
>>  1 files changed, 3 insertions(+), 8 deletions(-)
>>
>> diff --git a/cmd.c b/cmd.c
>> index f77897e..abcf206 100644
>> --- a/cmd.c
>> +++ b/cmd.c
>> @@ -49,7 +49,7 @@ void
>>  add_command(
>>       const cmdinfo_t *ci)
>>  {
>> -     cmdtab = realloc((void *)cmdtab, ++ncmds * sizeof(*cmdtab));
>> +    cmdtab = g_realloc((void *)cmdtab, ++ncmds * sizeof(*cmdtab));
>>       cmdtab[ncmds - 1] = *ci;
>>       qsort(cmdtab, ncmds, sizeof(*cmdtab), compare);
>>  }
>
> Inconsistent indentation.
>
> Either stick to the original indentation, or reindent the whole
> function.

I'll send second version with coding style fixes made in a separate commit.

-- 
Pavel

>
> [More of the same...]
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-10-31  7:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-10-28 21:48 [Qemu-devel] [PATCH] cmd: Fix potential NULL pointer dereference Pavel Borzenkov
2011-10-31  6:27 ` Markus Armbruster
2011-10-31  7:18   ` Pavel Borzenkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).