Browse Source

Prevent possible NULL pointer dereference.

Georgi Chorbadzhiyski 9 years ago
parent
commit
5ca51d520f
2 changed files with 6 additions and 0 deletions
  1. 4
    0
      cmd.c
  2. 2
    0
      display.c

+ 4
- 0
cmd.c View File

@@ -380,6 +380,10 @@ static unsigned int my_atoi(char *txt) {
380 380
 
381 381
 static void init_port_number(struct vcmd_param *p, struct port_set *port, const char *port_id) {
382 382
 	p->port_no = my_atoi(p->param);
383
+	if (!port) {
384
+		die("impossible! port == NULL");
385
+		return;
386
+	}
383 387
 	if (p->port_no == 0 || p->port_no > port->num) {
384 388
 		p->port_no = get_port_by_name(port, p->param);
385 389
 		if (!p->port_no)

+ 2
- 0
display.c View File

@@ -230,6 +230,8 @@ static void __print_opt(struct videohub_data *d, enum vcmd vcmd) {
230 230
 	struct videohub_commands *v = &videohub_commands[vcmd];
231 231
 	struct port_set *s_port = !v->ports1 ? NULL : (void *)d + v->ports1;
232 232
 	const char *p = v->opt_prefix;
233
+	if (!s_port)
234
+		return;
233 235
 	for(i = 0; i < s_port->num; i++) {
234 236
 		switch (v->type) {
235 237
 		case PARSE_LABEL:

Loading…
Cancel
Save