Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(254)

Side by Side Diff: src/cmd/gc/dcl.c

Issue 7838050: code review 7838050: cmd/gc: fix nil pointer dereferences. (Closed)
Patch Set: diff -r 1dc27f043b78 https://go.googlecode.com/hg/ Created 12 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/cmd/gc/subr.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 #include <u.h> 5 #include <u.h>
6 #include <libc.h> 6 #include <libc.h>
7 #include "go.h" 7 #include "go.h"
8 #include "y.tab.h" 8 #include "y.tab.h"
9 9
10 static void funcargs(Node*); 10 static void funcargs(Node*);
(...skipping 1321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1332 pa = getthisx(t)->type; // ptr to this structure 1332 pa = getthisx(t)->type; // ptr to this structure
1333 if(pa == T) { 1333 if(pa == T) {
1334 yyerror("missing receiver"); 1334 yyerror("missing receiver");
1335 return; 1335 return;
1336 } 1336 }
1337 1337
1338 pa = pa->type; 1338 pa = pa->type;
1339 f = methtype(pa, 1); 1339 f = methtype(pa, 1);
1340 if(f == T) { 1340 if(f == T) {
1341 t = pa; 1341 t = pa;
1342 if(t == T) // rely on typecheck having complained before
1343 return;
1342 if(t != T) { 1344 if(t != T) {
dave_cheney.net 2013/03/25 02:49:42 Do you need this check? The line above ensures if
1343 if(isptr[t->etype]) { 1345 if(isptr[t->etype]) {
1344 if(t->sym != S) { 1346 if(t->sym != S) {
1345 yyerror("invalid receiver type %T (%T is a pointer type)", pa, t); 1347 yyerror("invalid receiver type %T (%T is a pointer type)", pa, t);
1346 return; 1348 return;
1347 } 1349 }
1348 t = t->type; 1350 t = t->type;
1349 } 1351 }
1350 » » } 1352 » » » if(t->broke) // rely on typecheck having complained befo re
1351 » » if(t->broke) // rely on typecheck having complained before 1353 » » » » return;
1352 » » » return;
1353 » » if(t != T) {
1354 if(t->sym == S) { 1354 if(t->sym == S) {
1355 yyerror("invalid receiver type %T (%T is an unna med type)", pa, t); 1355 yyerror("invalid receiver type %T (%T is an unna med type)", pa, t);
1356 return; 1356 return;
1357 } 1357 }
1358 if(isptr[t->etype]) { 1358 if(isptr[t->etype]) {
1359 yyerror("invalid receiver type %T (%T is a point er type)", pa, t); 1359 yyerror("invalid receiver type %T (%T is a point er type)", pa, t);
1360 return; 1360 return;
1361 } 1361 }
1362 if(t->etype == TINTER) { 1362 if(t->etype == TINTER) {
1363 yyerror("invalid receiver type %T (%T is an inte rface type)", pa, t); 1363 yyerror("invalid receiver type %T (%T is an inte rface type)", pa, t);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1463 p = smprint("%s·f", s->name); 1463 p = smprint("%s·f", s->name);
1464 s1 = pkglookup(p, s->pkg); 1464 s1 = pkglookup(p, s->pkg);
1465 free(p); 1465 free(p);
1466 if(s1->def == N) { 1466 if(s1->def == N) {
1467 s1->def = newname(s1); 1467 s1->def = newname(s1);
1468 s1->def->shortname = newname(s); 1468 s1->def->shortname = newname(s);
1469 funcsyms = list(funcsyms, s1->def); 1469 funcsyms = list(funcsyms, s1->def);
1470 } 1470 }
1471 return s1; 1471 return s1;
1472 } 1472 }
OLDNEW
« no previous file with comments | « no previous file | src/cmd/gc/subr.c » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b