Re: [patch] pthread_setschedparam.3: Invalid free() in example code

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

 



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@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux