Skip to content
Snippets Groups Projects
Commit 7049fbf7 authored by Simon McVittie's avatar Simon McVittie
Browse files

inspect-library: Make memory management more obvious


We were relying on the fact that strsep(&line, ...) resets line to NULL
when it reaches the end, which is not at all obvious. Swap the roles
of the variables around.

Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
parent 2120ed8f
No related branches found
No related tags found
2 merge requests!21inspect-library: Add support for consuming deb-symbols(5) files,!20inspect-library: various fixes
......@@ -120,7 +120,6 @@ main (int argc,
size_t missing_n = 0;
size_t misversioned_n = 0;
char *line = NULL;
char *r = NULL;
size_t len = 0;
ssize_t chars;
bool first;
......@@ -198,13 +197,14 @@ main (int argc,
/* Skip any empty line */
if (chars > 1)
{
r = line;
symbol = strsep(&line, "@");
version = strsep(&line, "@");
char *pointer_into_line = line;
symbol = strsep (&pointer_into_line, "@");
version = strsep (&pointer_into_line, "@");
if (symbol == NULL)
{
fprintf (stderr, "Probably the symbol@version pair is mispelled.");
free (r);
free (line);
free (missing_symbols);
free (misversioned_symbols);
clean_exit (handle);
......@@ -230,7 +230,9 @@ main (int argc,
free (merged_string);
}
}
free (r);
free (line);
line = NULL;
len = 0;
}
}
free (line);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment