qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 2/6] block: vmdk - move string allocations fr


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH v2 2/6] block: vmdk - move string allocations from stack to the heap
Date: Thu, 22 Jan 2015 11:17:35 +0000
User-agent: Mutt/1.5.23 (2014-03-12)

On Tue, Jan 20, 2015 at 12:31:29PM -0500, Jeff Cody wrote:
> @@ -792,12 +792,11 @@ static int vmdk_parse_extents(const char *desc, 
> BlockDriverState *bs,
>      const char *p = desc;
>      int64_t sectors = 0;
>      int64_t flat_offset;
> -    char extent_path[PATH_MAX];
> +    char *extent_path = g_malloc0(PATH_MAX);

Simpler alternative that has no risk of memory leaks:

  extent_path = g_malloc0(PATH_MAX);
  path_combine(extent_path, sizeof(extent_path),
          desc_file_path, fname);
  extent_file = NULL;
  ret = bdrv_open(&extent_file, extent_path, NULL, NULL,
                  bs->open_flags | BDRV_O_PROTOCOL, NULL, errp);
  g_free(extent_path);
  if (ret) {
      goto exit;
  }

Attachment: pgpn6WXFrf5I2.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]