Bug 253272

Summary: s_maxSize should be 'unsigned' rather than 'int' in WidthCache.h
Product: WebKit Reporter: Ahmad Saleem <ahmad.saleem792>
Component: Layout and RenderingAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, bfulgham, ggaren, mmaxfield, ntim, simon.fraser, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Description Ahmad Saleem 2023-03-02 15:25:27 PST
Hi Team,

I noticed that 's_maxSize' is int and it means that it can be negative while I think cache should be 0 or positive for which we should have it as 'unsigned'.

WebKit Source - https://searchfox.org/wubkat/source/Source/WebCore/platform/graphics/WidthCache.h#217

static const int s_maxSize = 500000;

Appreciate if someone can confirm my understanding and I am happy to do PR to fix it.

Thanks!
Comment 1 Ahmad Saleem 2023-03-04 18:37:54 PST
Just noticed that above - https://searchfox.org/wubkat/source/Source/WebCore/platform/graphics/WidthCache.h#204

There is this as well, where size() is unsigned in HashMap.h:

m_map.size() < s_maxSize

https://searchfox.org/wubkat/source/Source/WTF/wtf/HashMap.h#267

So we are comparing 'unsigned' with 'int'.
Comment 2 Myles C. Maxfield 2023-03-05 00:21:34 PST
Yes, the thing it's compared to is an unsigned, so it should be an unsigned too.
Comment 3 Ahmad Saleem 2023-03-05 04:12:23 PST
PR - https://github.com/WebKit/WebKit/pull/11082
Comment 4 EWS 2023-03-05 20:06:06 PST
Committed 261252@main (315cbcb64568): <https://commits.webkit.org/261252@main>

Reviewed commits have been landed. Closing PR #11082 and removing active labels.
Comment 5 Radar WebKit Bug Importer 2023-03-05 20:07:16 PST
<rdar://problem/106270278>