public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Andreas Schwab <schwab@suse.de>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH] manual: Various fixes to the mbstouwcs example
Date: Thu, 05 Apr 2018 10:13:00 -0000	[thread overview]
Message-ID: <d7d4c92b-b90e-2da6-423f-a3217b951839@redhat.com> (raw)
In-Reply-To: <mvmd0ze2ceq.fsf@suse.de>

On 04/05/2018 12:08 PM, Andreas Schwab wrote:
> On Apr 05 2018, Florian Weimer <fweimer@redhat.com> wrote:
> 
>> @@ -7,22 +8,46 @@
>>   wchar_t *
>>   mbstouwcs (const char *s)
>>   {
>> -  size_t len = strlen (s);
>> -  wchar_t *result = malloc ((len + 1) * sizeof (wchar_t));
>> +  /* Include the NUL terminator in the conversion.  */
>> +  size_t len = strlen (s) + 1;
>> +  wchar_t *result = reallocarray (NULL, len + 1, sizeof (wchar_t));
> 
> I still think that result[len] is never used.  The conversion of a
> multibyte string with len bytes can generate at most len wide
> characters.

Oh, right, I'm adding 1 twice.  Fixed locally.

Any further comments?

Thanks,
Florian

  reply	other threads:[~2018-04-05 10:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-04 13:57 Florian Weimer
2018-04-04 14:19 ` Andreas Schwab
2018-04-05  9:56   ` Florian Weimer
2018-04-05 10:08     ` Andreas Schwab
2018-04-05 10:13       ` Florian Weimer [this message]
2018-04-05 10:49         ` Andreas Schwab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d7d4c92b-b90e-2da6-423f-a3217b951839@redhat.com \
    --to=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=schwab@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).