[PATCH 1/2] xcursor: Fix allocation based on string length

Rob Bradford robert.bradford at intel.com
Tue Oct 9 10:46:21 PDT 2012


From: Rob Bradford <rob at linux.intel.com>

strlen() doesn't include the terminating NUL. Therefore when allocating a
block of memory to hold something equivalent to the length of the string we
must increment to take the NUL byte into consideration.

Signed-off-by: Rob Bradford <rob at linux.intel.com>
---
 cursor/xcursor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cursor/xcursor.c b/cursor/xcursor.c
index 1f66bce..7a9662a 100644
--- a/cursor/xcursor.c
+++ b/cursor/xcursor.c
@@ -757,7 +757,7 @@ _XcursorThemeInherits (const char *full)
 		if (*l != '=') continue;
 		l++;
 		while (*l == ' ') l++;
-		result = malloc (strlen (l));
+		result = malloc (strlen (l) + 1);
 		if (result)
 		{
 		    r = result;
-- 
1.7.11.2



More information about the wayland-devel mailing list