summaryrefslogtreecommitdiff
path: root/dselect
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2010-02-20 06:16:11 +0100
committerGuillem Jover <guillem@debian.org>2010-02-25 09:37:39 +0100
commitecf0b87226f0db54551e2d34fca6fa45542f52a2 (patch)
treefb9f6098f6538b399766bc1fdbffcadd9e6300b2 /dselect
parent3e9f202bc125eeaf291c47613f5e42493077fd42 (diff)
downloaddpkg-ecf0b87226f0db54551e2d34fca6fa45542f52a2.tar.gz
dselect: Use m_strdup instead of unchecked malloc + strcpy
This would cause a segfault in an OOM situation.
Diffstat (limited to 'dselect')
-rw-r--r--dselect/main.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/dselect/main.cc b/dselect/main.cc
index da9c0de5e..df0137069 100644
--- a/dselect/main.cc
+++ b/dselect/main.cc
@@ -259,11 +259,11 @@ extern "C" {
* --color selstate::reverse // doesn't work FIXME
*/
static void setcolor(const struct cmdinfo*, const char *string) {
- char *s= (char *) malloc((strlen(string) + 1) * sizeof(char));
+ char *s;
char *colours, *attributes, *attrib, *colourname;
int screenpart, aval;
- strcpy(s, string); // strtok modifies strings, keep string const
+ s = m_strdup(string); // strtok modifies strings, keep string const
screenpart= findintable(screenparttable, strtok(s, ":"), _("screen part"));
colours= strtok(NULL, ":");
attributes= strtok(NULL, ":");