This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Add OSE operating system support [1/5] ose core format support of bfd


>>>>> "Hui" == Hui Zhu <hui_zhu@mentor.com> writes:

Hui> OSE's core file format is different compared to Linux, so there is
Hui> patch for bfd to handle this format.

I skimmed this a little and a couple things caught my attention.

Hui> +struct ose_core_struct
Hui> +{
Hui> +  /* FIXME: we aren't setting these anywhere yet.  */
Hui> +  int sig;
Hui> +  int bid;
Hui> +};

If that is the case, why not just delete this entirely?
You can re-add it whenever it is needed.

Hui> +/* FIXME: should not be a global.  */
Hui> +int last_data_section;

I think this can just be a local variable where it is used.

Hui> +static bfd_boolean
Hui> +zlib_inflate_buffer (bfd_byte *compressed_buffer,
Hui> +		     size_t compressed_size,
Hui> +		     bfd_byte *uncompressed_buffer,
Hui> +		     bfd_size_type uncompressed_size)
[...]

Hui> +  rc = inflateInit (&strm);
Hui> +  while (strm.avail_in > 0)
Hui> +    {
Hui> +      if (rc != Z_OK)
Hui> +	return FALSE;
Hui> +      strm.next_out = ((Bytef *) uncompressed_buffer
Hui> +		       + (uncompressed_size - strm.avail_out));
Hui> +      rc = inflate (&strm, Z_FINISH);
Hui> +      if (rc != Z_STREAM_END)
Hui> +	return FALSE;
Hui> +      rc = inflateReset (&strm);
Hui> +    }
Hui> +  rc = inflateEnd (&strm);
Hui> +  if (rc != Z_OK
Hui> +      || strm.avail_out != 0)
Hui> +    return FALSE;

This can leak memory at the 'return FALSE' statements in the loop.
I think it should call inflateEnd before each return.

Tom


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]