mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
* util.c (load_file_position): Fixed possible segmentation fault
when an $HOME/.mc/filepos did not contain a ';'.
This commit is contained in:
parent
e9fcc04816
commit
3c09855c2d
@ -1,3 +1,8 @@
|
||||
2004-09-24 Roland Illig <roland.illig@gmx.de>
|
||||
|
||||
* util.c (load_file_position): Fixed possible segmentation fault
|
||||
when an $HOME/.mc/filepos did not contain a ';'.
|
||||
|
||||
2004-09-24 Roland Illig <roland.illig@gmx.de>
|
||||
|
||||
* boxes.c: Replaced NULL with (char *) NULL. Likewise for 0, where
|
||||
|
12
src/util.c
12
src/util.c
@ -1327,7 +1327,7 @@ load_file_position (const char *filename, long *line, long *column)
|
||||
len = strlen (filename);
|
||||
|
||||
while (fgets (buf, sizeof (buf), f)) {
|
||||
char *p;
|
||||
const char *p;
|
||||
|
||||
/* check if the filename matches the beginning of string */
|
||||
if (strncmp (buf, filename, len) != 0)
|
||||
@ -1342,9 +1342,13 @@ load_file_position (const char *filename, long *line, long *column)
|
||||
if (strchr (p, ' '))
|
||||
continue;
|
||||
|
||||
*line = atol (p);
|
||||
p = strchr (buf, ';');
|
||||
*column = atol (&p[1]);
|
||||
*line = strtol(p, const_cast(char **, &p), 10);
|
||||
if (*p == ';') {
|
||||
*column = strtol(p, const_cast(char **, &p), 10);
|
||||
if (*p != '\n')
|
||||
*column = 0;
|
||||
} else
|
||||
*line = 1;
|
||||
}
|
||||
fclose (f);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user