comparison searching.c @ 436:a566d307173d src

Avoid a crash when program number is zero. This is a workaround for a crash at: cellnr = pgc->program_map[ptt[i].pgn-1]; when playing "The Dictator". Based on a patch by Ivan Kalvachev < ikalvachev AT gmail DOT com>.
author rathann
date Mon, 11 Nov 2013 23:49:17 +0000
parents fef53ca48541
children d8ec83537d07
comparison
equal deleted inserted replaced
435:29d4a43c8c86 436:a566d307173d
627 } 627 }
628 if (pgc->program_map == NULL) { 628 if (pgc->program_map == NULL) {
629 printerr("Program map missing."); 629 printerr("Program map missing.");
630 continue; 630 continue;
631 } 631 }
632 if(ptt[i].pgn > pgc->nr_of_programs) { 632 if(ptt[i].pgn == 0 || ptt[i].pgn > pgc->nr_of_programs) {
633 printerr("WRONG part number."); 633 printerr("WRONG part number.");
634 goto fail; 634 goto fail;
635 } 635 }
636 636
637 if (pgc->nr_of_cells == 0) { 637 if (pgc->nr_of_cells == 0) {