intel: Only check string if length > 0
strncmp will return 0 (match) when given two different strings
and a length of 0. Changed code to only do the compare if
length > 0. Now properly handles empty environment variable or
one that has multiple commas in a row.
diff --git a/icd/intel/intel.c b/icd/intel/intel.c
index 106f1eb..6cd0fa0 100644
--- a/icd/intel/intel.c
+++ b/icd/intel/intel.c
@@ -53,13 +53,15 @@
else
len = strlen(env);
- if (strncmp(env, "batch", len) == 0) {
- intel_debug |= INTEL_DEBUG_BATCH;
- } else if (strncmp(env, "nohw", len) == 0) {
- intel_debug |= INTEL_DEBUG_NOHW;
- } else if (strncmp(env, "0x", 2) == 0) {
- intel_debug |= INTEL_DEBUG_NOHW;
- intel_devid_override = strtol(env, NULL, 16);
+ if (len > 0) {
+ if (strncmp(env, "batch", len) == 0) {
+ intel_debug |= INTEL_DEBUG_BATCH;
+ } else if (strncmp(env, "nohw", len) == 0) {
+ intel_debug |= INTEL_DEBUG_NOHW;
+ } else if (strncmp(env, "0x", 2) == 0) {
+ intel_debug |= INTEL_DEBUG_NOHW;
+ intel_devid_override = strtol(env, NULL, 16);
+ }
}
if (!p)