Skip to content

Commit f2e3d5c

Browse files
authored
Merge pull request #45 from bshannon/issue_33
Avoid segfault due to null pointer when given "From: <a@b.com" - fixes #33
2 parents a727a82 + a0a352c commit f2e3d5c

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/getname.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,14 @@ void getname(char *line, char **namep, char **emailp)
249249
}
250250
else if (*c == '<') { /* Comment may be on the end */
251251
/* From: <bill@celestial.com> Bill Campbell */
252-
c = strchr(line, '>') + 1;
253-
for (i = 0, len = NAMESTRLEN - 1; *c && *c != '\n' && i < len; c++)
254-
name[i++] = *c;
252+
char *c2 = strchr(line, '>');
253+
if (c2 != NULL) {
254+
c = c2 + 1;
255+
for (i = 0, len = NAMESTRLEN - 1; *c && *c != '\n' && i < len; c++)
256+
name[i++] = *c;
255257

256-
comment_fnd = 1;
258+
comment_fnd = 1;
259+
}
257260
}
258261
}
259262
else if (strchr(line, '(')) {

0 commit comments

Comments
 (0)