mirror of
https://github.com/systemd/systemd.git
synced 2024-10-27 18:55:40 +03:00
string-util: make sure strrepa() doesn't doubly evaluate expressions
This commit is contained in:
parent
94a8a4b063
commit
b22635083a
@ -202,11 +202,14 @@ char *strrep(const char *s, unsigned n);
|
||||
|
||||
#define strrepa(s, n) \
|
||||
({ \
|
||||
const char *_sss_ = (s); \
|
||||
size_t _nnn_ = (n), _len_ = strlen(_sss_); \
|
||||
assert(!size_multiply_overflow(_len_, _nnn_)); \
|
||||
_len_ *= _nnn_; \
|
||||
char *_d_, *_p_; \
|
||||
size_t _len_ = strlen(s) * n; \
|
||||
_p_ = _d_ = newa(char, _len_ + 1); \
|
||||
for (unsigned _i_ = 0; _i_ < n; _i_++) \
|
||||
_p_ = stpcpy(_p_, s); \
|
||||
for (size_t _i_ = 0; _i_ < _nnn_; _i_++) \
|
||||
_p_ = stpcpy(_p_, _sss_); \
|
||||
*_p_ = 0; \
|
||||
_d_; \
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user