]> err.no Git - pkg-config/commitdiff
Fix possible off-by-one
authorTollef Fog Heen <tfheen@err.no>
Sat, 1 Oct 2005 10:13:57 +0000 (10:13 +0000)
committerTollef Fog Heen <tfheen@err.no>
Sat, 1 Oct 2005 10:13:57 +0000 (10:13 +0000)
Apply last part of patch from freedesktop #4034 so we don't do silly
things if len is zero.

pkg.c

diff --git a/pkg.c b/pkg.c
index 70ff9ced51f71ad9e94ff28744460b6bf146b87c..dbb4288cd8e8c60a2f9206e7ce6ce5f9bc89a778 100644 (file)
--- a/pkg.c
+++ b/pkg.c
@@ -1241,7 +1241,8 @@ packages_get_var (GSList     *pkgs,
     }
 
   /* chop last space */
-  str->str[str->len - 1] = '\0';
+  if (str->len > 0)
+      str->str[str->len - 1] = '\0';
   retval = str->str;
   g_string_free (str, FALSE);