fix: hard-fail JPEGDEC patch loader when patches are missing
Silently returning when scripts/jpegdec_patches/ is missing or empty would let the build succeed shipping an unpatched JPEGDEC, which re-introduces the wild-pointer + black-image bugs without warning. Raise RuntimeError in _patch_files() in both cases.
This commit is contained in:
@@ -30,8 +30,6 @@ def patch_jpegdec(env):
|
|||||||
if not os.path.isdir(libdeps_dir):
|
if not os.path.isdir(libdeps_dir):
|
||||||
return
|
return
|
||||||
patches = _patch_files()
|
patches = _patch_files()
|
||||||
if not patches:
|
|
||||||
return
|
|
||||||
for env_dir in os.listdir(libdeps_dir):
|
for env_dir in os.listdir(libdeps_dir):
|
||||||
jpeg_dir = os.path.join(libdeps_dir, env_dir, "JPEGDEC")
|
jpeg_dir = os.path.join(libdeps_dir, env_dir, "JPEGDEC")
|
||||||
if not os.path.isdir(os.path.join(jpeg_dir, ".git")):
|
if not os.path.isdir(os.path.join(jpeg_dir, ".git")):
|
||||||
@@ -42,12 +40,21 @@ def patch_jpegdec(env):
|
|||||||
|
|
||||||
def _patch_files():
|
def _patch_files():
|
||||||
if not os.path.isdir(PATCH_DIR):
|
if not os.path.isdir(PATCH_DIR):
|
||||||
return []
|
raise RuntimeError(
|
||||||
return sorted(
|
"JPEGDEC patches missing -- aborting build (expected directory %s)"
|
||||||
|
% PATCH_DIR
|
||||||
|
)
|
||||||
|
patches = sorted(
|
||||||
os.path.join(PATCH_DIR, name)
|
os.path.join(PATCH_DIR, name)
|
||||||
for name in os.listdir(PATCH_DIR)
|
for name in os.listdir(PATCH_DIR)
|
||||||
if name.endswith(".patch")
|
if name.endswith(".patch")
|
||||||
)
|
)
|
||||||
|
if not patches:
|
||||||
|
raise RuntimeError(
|
||||||
|
"JPEGDEC patches missing -- aborting build (no .patch files in %s)"
|
||||||
|
% PATCH_DIR
|
||||||
|
)
|
||||||
|
return patches
|
||||||
|
|
||||||
|
|
||||||
def _apply_one(jpeg_dir, patch_path):
|
def _apply_one(jpeg_dir, patch_path):
|
||||||
|
|||||||
Reference in New Issue
Block a user