aboutsummaryrefslogtreecommitdiffstats
path: root/lib/parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/parser.c')
-rw-r--r--lib/parser.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/parser.c b/lib/parser.c
index fb34977246bb..dcbaaef6cf11 100644
--- a/lib/parser.c
+++ b/lib/parser.c
@@ -13,7 +13,7 @@
13 13
14/** 14/**
15 * match_one: - Determines if a string matches a simple pattern 15 * match_one: - Determines if a string matches a simple pattern
16 * @s: the string to examine for presense of the pattern 16 * @s: the string to examine for presence of the pattern
17 * @p: the string containing the pattern 17 * @p: the string containing the pattern
18 * @args: array of %MAX_OPT_ARGS &substring_t elements. Used to return match 18 * @args: array of %MAX_OPT_ARGS &substring_t elements. Used to return match
19 * locations. 19 * locations.
@@ -128,12 +128,13 @@ static int match_number(substring_t *s, int *result, int base)
128 char *endp; 128 char *endp;
129 char *buf; 129 char *buf;
130 int ret; 130 int ret;
131 size_t len = s->to - s->from;
131 132
132 buf = kmalloc(s->to - s->from + 1, GFP_KERNEL); 133 buf = kmalloc(len + 1, GFP_KERNEL);
133 if (!buf) 134 if (!buf)
134 return -ENOMEM; 135 return -ENOMEM;
135 memcpy(buf, s->from, s->to - s->from); 136 memcpy(buf, s->from, len);
136 buf[s->to - s->from] = '\0'; 137 buf[len] = '\0';
137 *result = simple_strtol(buf, &endp, base); 138 *result = simple_strtol(buf, &endp, base);
138 ret = 0; 139 ret = 0;
139 if (endp == buf) 140 if (endp == buf)