Remove offset pointer optimization in inftrees.c #292

Closed
Mrcopytuo wants to merge 1 commits from Mrcopytuo/kolibrios:fix-inftrees into main
First-time contributor

Description

This PR applies the same fix as
6a043145ca

The change removes the offset pointer optimization in inftrees.c and replaces it with a C-standard-compliant implementation.

The previous implementation relied on pointer arithmetic that subtracts an offset from a pointer and then indexes from that location. While this worked in practice, it can result in undefined behavior according to the C standard.


Changes

  • Removed offset-based pointer arithmetic in inftrees.c
  • Reworked index calculations to avoid undefined pointer behavior
  • Preserved the original logic and behavior while improving safety and portability

Reference

Upstream commit for comparison:
6a043145ca

## Description This PR applies the same fix as https://github.com/madler/zlib/commit/6a043145ca6e9c55184013841a67b2fef87e44c0 The change removes the offset pointer optimization in `inftrees.c` and replaces it with a C-standard-compliant implementation. The previous implementation relied on pointer arithmetic that subtracts an offset from a pointer and then indexes from that location. While this worked in practice, it can result in undefined behavior according to the C standard. --- ## Changes - Removed offset-based pointer arithmetic in `inftrees.c` - Reworked index calculations to avoid undefined pointer behavior - Preserved the original logic and behavior while improving safety and portability --- ## Reference Upstream commit for comparison: https://github.com/madler/zlib/commit/6a043145ca6e9c55184013841a67b2fef87e44c0
Mrcopytuo added 1 commit 2025-12-16 06:24:06 +00:00
更新 contrib/sdk/sources/zlib/inftrees.c
All checks were successful
Build system / Check kernel codestyle (pull_request) Successful in 2m4s
Build system / Build (pull_request) Successful in 16m9s
27f411089e
Burer approved these changes 2025-12-21 13:55:54 +00:00
Owner
See: https://git.kolibrios.org/KolibriOS/kolibrios/pulls/300#issuecomment-3798
mxlgv closed this pull request 2026-01-07 01:35:42 +00:00
All checks were successful
Build system / Check kernel codestyle (pull_request) Successful in 2m4s
Required
Details
Build system / Build (pull_request) Successful in 16m9s
Required
Details

Pull request closed

Sign in to join this conversation.
No Reviewers
3 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: KolibriOS/kolibrios#292