From a59a8d3e9293db588c7d78bbc8e853deef2d820d Mon Sep 17 00:00:00 2001 From: John Kerl Date: Thu, 17 Dec 2015 09:38:50 -0500 Subject: [PATCH] valgrind findings --- c/lib/mlrutil.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/c/lib/mlrutil.h b/c/lib/mlrutil.h index 31fc2fefa..5ef2acd81 100644 --- a/c/lib/mlrutil.h +++ b/c/lib/mlrutil.h @@ -47,7 +47,7 @@ static inline int streqn(char* a, char* b, int n) { #if 0 // performance comparison return !strncmp(a, b, n); #else - while (*a && *b) { + while (n > 0 && *a && *b) { if (n-- <= 0) { return TRUE; } @@ -57,8 +57,10 @@ static inline int streqn(char* a, char* b, int n) { a++; b++; } + if (n == 0) + return TRUE; if (*a || *b) { - return (n <= 0) ? TRUE : FALSE; + return FALSE; } return TRUE; #endif