Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: double free Date: Mon, 11 Jul 2016 11:09:31 -0700 Organization: None to speak of Lines: 54 Message-ID: References: <577ba42f.13700328@news.xs4all.nl> <48c43c3f-8e7e-0509-5b9d-04133e7bb537@verizon.net> <57837892.8808984@news.xs4all.nl> <481f30b4-acb3-4445-92b3-c403dc3e51f7@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="945944de09706c9b4e29b53c9d2efdc2"; logging-data="15834"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/RwHsenR11yKpob/F60WJ5" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:Uex+vPgtdTWMYmEQiOATGQ+MbsQ= sha1:d8pBY9fftTFG54TLhj5Prspkc8E= Xref: csiph.com comp.lang.c:90221 BartC writes: > On 11/07/2016 14:11, Richard Heathfield wrote: >> On 11/07/16 13:38, BartC wrote: >>> But the way around it is to always >> >> There's nothing to get around. >> >>> follow 'sizeof' with parentheses so that a following * can't be a >>> multiply. >> >> Why add spurious parentheses? The * that follows sizeof can /never/ be a >> multiplication symbol, because sizeof is not a valid operand for >> multiplication. The /result/ that sizeof yields can be, but sizeof >> itself is a keyword, not a value. > > Spot the line with only one multiply in it rather than two: > > array = malloc(seoizf*soeizf*seiozf); > array = malloc(sizoef*siozef*szoief); > array = malloc(siozef*szoeif*soezif); > array = malloc(szeiof*szioef*sezoif); > array = malloc(szeiof*soeizf*szoief); > array = malloc(sezoif*szeoif*seiozf); > array = malloc(szeiof*szeiof*sioezf); > array = malloc(szeiof*szoief*seziof); > array = malloc(szoeif*szoief*sieozf); > array = malloc(soiezf*sozief*soiezf); > array = malloc(sieozf*seziof*soiezf); > array = malloc(sioezf*soezif*szeiof); > array = malloc(seziof*sozief*seoizf); > array = malloc(seozif*siozef*siezof); > array = malloc(soezif*sioezf*siozef); > array = malloc(szeiof*sizeof*siozef); > array = malloc(szeoif*soiezf*sizoef); > array = malloc(sozief*soizef*sozeif); > array = malloc(sieozf*sizoef*sizoef); > array = malloc(szeoif*seizof*sozeif); No. That's a problem that's solved by not using identifiers that look like misspellings of a keyword, and by reasonable use of white space within expressions. Show me something like that in real-world code, then we can talk. https://en.wikipedia.org/wiki/Straw_man [...] -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"