pulse-server: make sure we don't exceed maxlength

Make sure the various buffer attributes don't exceed maxlength.
Add some SPA_ROUND_UP and SPA_ROUND_DOWN macros.

Fixes #2100
This commit is contained in:
Wim Taymans 2022-02-04 11:59:57 +01:00
parent 877dc77645
commit 8c10080324
2 changed files with 15 additions and 13 deletions

View file

@ -228,6 +228,9 @@ struct spa_fraction {
#define SPA_RESTRICT
#endif
#define SPA_ROUND_DOWN(num,value) ((num) - ((num) % (value)))
#define SPA_ROUND_UP(num,value) ((((num) + (value) - 1) / (value)) * (value))
#define SPA_ROUND_DOWN_N(num,align) ((num) & ~((align) - 1))
#define SPA_ROUND_UP_N(num,align) SPA_ROUND_DOWN_N((num) + ((align) - 1),align)