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

+ 2
- 0
display.c View File

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

Loading…
Cancel
Save