All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael Kerrisk (man-pages)" <mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Simon Newton <nomis52-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [patch] pthread_setschedparam.3: Invalid free() in example code
Date: Tue, 23 Dec 2014 16:31:27 +0100	[thread overview]
Message-ID: <54998ACF.8020800@gmail.com> (raw)
In-Reply-To: <CAPQm1=PpBDnu9jW=0zuYF5X853F1HHomn3Po9vLMZ78LHq=thg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>

Hello Simon,

On 11/29/2014 06:41 PM, Simon Newton wrote:
> The example program will crash if -A is used, since attr is uninitialized.
> 
> $ ./a.out  -A
> *** Error in `./a.out': free(): invalid pointer: 0xb779c3c4 ***
> Aborted (core dumped)
> 
> 
> 
> diff --git a/man3/pthread_setschedparam.3 b/man3/pthread_setschedparam.3
> index 971bc0c..36b00bd 100644
> --- a/man3/pthread_setschedparam.3
> +++ b/man3/pthread_setschedparam.3
> @@ -424,9 +424,11 @@ main(int argc, char *argv[])
> 
>      /* Destroy unneeded thread attributes object */
> 
> -    s = pthread_attr_destroy(&attr);
> -    if (s != 0)
> -        handle_error_en(s, "pthread_attr_destroy");
> +    if (!use_null_attrib) {
> +      s = pthread_attr_destroy(&attr);
> +      if (s != 0)
> +          handle_error_en(s, "pthread_attr_destroy");
> +    }
> 
>      s = pthread_join(thread, NULL);
>      if (s != 0)

Thanks! Applied.

Cheers,

Michael




-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

      parent reply	other threads:[~2014-12-23 15:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-29 17:41 [patch] pthread_setschedparam.3: Invalid free() in example code Simon Newton
     [not found] ` <CAPQm1=PpBDnu9jW=0zuYF5X853F1HHomn3Po9vLMZ78LHq=thg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-12-23 15:31   ` Michael Kerrisk (man-pages) [this message]

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=54998ACF.8020800@gmail.com \
    --to=mtk.manpages-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=nomis52-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.