Skip to content

gfileutils: Correct operator precedence to avoid undefined pointer maths

Philip Withnall requested to merge pwithnall/glib:2077-pointer-arithmetic into master

base can be -1 in some situations, which would lead to pointing outside an allocation area if the sums were evaluated as (file_name + base) + 1 rather than file_name + (base + 1).

I don’t see how this can practically cause an issue, as the arithmetic is all finished before anything’s dereferenced, but let’s keep to the letter of the C standard to avoid this coming up in code audits in future.

Fix suggested by fablhx.

Signed-off-by: Philip Withnall withnall@endlessm.com

Closes: #2077 (closed)

Merge request reports