Re: [OT] C programming problem

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

 



Hi Wol,

Bug alert!

On 02/07/2018 02:46 PM, Wol's lists wrote:
> void main()
> {

>     blocks = logdisks * mirrors * disks;
>     array = (int *) malloc( sizeof(int) * blocks );
>     memset( &array, 0, blocks * sizeof(int) );
              ^^^^^^

Your 'array' variable is already a pointer.  You should not have
another address-of operator in front of it.  You are overwriting
your pointer and a bunch of static memory right after it, not
zeroing the area pointed to by 'array'.

Phil
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux