no check for a failled malloc
(1) By anonymous on 2021-09-13 13:19:24 [source]
hello!
as subject says, it looks like you missed some malloc checks a few times.
here
pSub
is dereferenced and unchecked. you may claim that allocation ofp->pSrc
is checked before and therefore there's no chance thatpSub
is not allocated but size ofstruct SrcList
(which issizeof(*p->pSrc)
) is MUCH smaller than size ofstruct Select
(which issizeof(*pSub)
) therefore one could succeed and one could not. to me it would be better if a condition on a line 1069 would check state of the flagdb->mallocFailed
.here you may see that
pE2
is unchecked. yeah, here it is very unlikely that pE2 allocation would fail and pEq allocation would succeed because they have the same size but to me it looks like juggling with knives to some extent. to me it would also be better if in the condition on line 350 you would check for a flagdb->mallocFailed
(2.1) By Richard Hipp (drh) on 2021-09-13 18:17:35 edited from 2.0 in reply to 1 [link] [source]
Thanks for the report.
The first bullet is not possible because of this line that forces p->pSrc to be NULL if pSub is NULL. Similarly the second bullet is not possible because the test of db->mallocFailed down inside of sqlite3DbMallocRawNN() causes pEq to be NULL if pE2 is NULL.
So, neither of these cases are actual problems. No action required.
Edit: See also check-in 83a83475c5064ea6.