From: Andreas Beckmann <debian@abeckmann.de>
Subject: simplify path overflow error handling
"path too long" is not a fatal error, there may be other search paths
that don't overflow, so try them as well
Index: b/src/vdpau_wrapper.c
===================================================================
--- a/src/vdpau_wrapper.c
+++ b/src/vdpau_wrapper.c
@@ -117,25 +117,23 @@
vdpau_driver = "nvidia";
}
+ _vdp_driver_dll = NULL;
if (snprintf(vdpau_driver_lib, sizeof(vdpau_driver_lib), DRIVER_LIB_FORMAT,
VDPAU_MODULEDIR "/", vdpau_driver, ".1") >=
sizeof(vdpau_driver_lib)) {
fprintf(stderr, "Failed to construct driver path: path too long\n");
- if (vdpau_driver_dri2) {
- XFree(vdpau_driver_dri2);
- vdpau_driver_dri2 = NULL;
- }
- _VDP_ERROR_BREAKPOINT();
- return VDP_STATUS_NO_IMPLEMENTATION;
+ } else {
+ _vdp_driver_dll = dlopen(vdpau_driver_lib, RTLD_NOW | RTLD_GLOBAL);
}
- _vdp_driver_dll = dlopen(vdpau_driver_lib, RTLD_NOW | RTLD_GLOBAL);
if (!_vdp_driver_dll) {
- /* Try again using the old path, which is guaranteed to fit in PATH_MAX
- * if the complete path fit above. */
- snprintf(vdpau_driver_lib, sizeof(vdpau_driver_lib), DRIVER_LIB_FORMAT,
- "", vdpau_driver, "");
- _vdp_driver_dll = dlopen(vdpau_driver_lib, RTLD_NOW | RTLD_GLOBAL);
+ /* Try again using the old path. */
+ if (snprintf(vdpau_driver_lib, sizeof(vdpau_driver_lib), DRIVER_LIB_FORMAT,
+ "", vdpau_driver, "") >= sizeof(vdpau_driver_lib)) {
+ fprintf(stderr, "Failed to construct driver path: path too long\n");
+ } else {
+ _vdp_driver_dll = dlopen(vdpau_driver_lib, RTLD_NOW | RTLD_GLOBAL);
+ }
}
if (vdpau_driver_dri2) {