Fix critical map issue

This commit is contained in:
Victor Shcherb 2012-08-18 21:06:02 +02:00
parent 7a715eb931
commit 7689a50bce
4 changed files with 15 additions and 13 deletions

View file

@ -49,7 +49,7 @@ public class BinaryInspector {
// test cases show info // test cases show info
// inspector(new String[]{/*"-vmap", "-bbox=-121.785,37.35,-121.744,37.33", */"/home/victor/projects/OsmAnd/data/osm-gen/Map.obf"}); // inspector(new String[]{/*"-vmap", "-bbox=-121.785,37.35,-121.744,37.33", */"/home/victor/projects/OsmAnd/data/osm-gen/Austria_2.obf"});
// test case extract parts // test case extract parts
// test case // test case
} }

View file

@ -61,6 +61,7 @@
<string name="tip_recent_changes_0_8_2_t">Changes in 0.8.2 : <string name="tip_recent_changes_0_8_2_t">Changes in 0.8.2 :
\n\t* Improved Routing \n\t* Improved Routing
\n\t* Dynamic map widgets \n\t* Dynamic map widgets
\n\t* Lock screen button with logging services
\n\t* Map settings moved to map screen \n\t* Map settings moved to map screen
</string> </string>
<string name="continue_follow_previous_route_auto">Previous navigation was unfinished. Continue following it? (%1$s seconds)</string> <string name="continue_follow_previous_route_auto">Previous navigation was unfinished. Continue following it? (%1$s seconds)</string>

View file

@ -125,7 +125,7 @@ public class SettingsActivity extends PreferenceActivity implements OnPreference
return getString(in); return getString(in);
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); System.err.println(e.getMessage());
} }
return defValue; return defValue;
} }

View file

@ -131,17 +131,17 @@ bool readMapLevel(CodedInputStream* input, MapRoot* root, bool initSubtrees) {
break; break;
} }
case OsmAndMapIndex_MapRootLevel::kBoxesFieldNumber: { case OsmAndMapIndex_MapRootLevel::kBoxesFieldNumber: {
if (!initSubtrees) {
input->Skip(input->BytesUntilLimit());
break;
}
MapTreeBounds bounds; MapTreeBounds bounds;
readInt(input, &bounds.length); readInt(input, &bounds.length);
bounds.filePointer = input->getTotalBytesRead(); bounds.filePointer = input->getTotalBytesRead();
if(initSubtrees){
int oldLimit = input->PushLimit(bounds.length); int oldLimit = input->PushLimit(bounds.length);
readMapTreeBounds(input, &bounds, root); readMapTreeBounds(input, &bounds, root);
root->bounds.push_back(bounds); root->bounds.push_back(bounds);
input->PopLimit(oldLimit); input->PopLimit(oldLimit);
} else {
input->Skip(input->BytesUntilLimit());
}
break; break;
} }
@ -911,9 +911,10 @@ ResultPublisher* searchObjectsForRendering(SearchQuery* q, bool skipDuplicates,
FileInputStream input(file->fd); FileInputStream input(file->fd);
input.SetCloseOnDelete(false); input.SetCloseOnDelete(false);
CodedInputStream cis(&input); CodedInputStream cis(&input);
cis.SetTotalBytesLimit(INT_MAX, INT_MAX >> 1);
cis.Seek(mapIndex->filePointer); cis.Seek(mapIndex->filePointer);
int oldLimit = cis.PushLimit(mapIndex->length); int oldLimit = cis.PushLimit(mapIndex->length);
readMapIndex(&cis, mapIndex, true); readMapIndex(&cis, &(*mapIndex), true);
cis.PopLimit(oldLimit); cis.PopLimit(oldLimit);
} }
// lazy initializing subtrees // lazy initializing subtrees
@ -922,10 +923,10 @@ ResultPublisher* searchObjectsForRendering(SearchQuery* q, bool skipDuplicates,
FileInputStream input(file->fd); FileInputStream input(file->fd);
input.SetCloseOnDelete(false); input.SetCloseOnDelete(false);
CodedInputStream cis(&input); CodedInputStream cis(&input);
cis.SetTotalBytesLimit(INT_MAX, INT_MAX >> 1);
cis.Seek(mapLevel->filePointer); cis.Seek(mapLevel->filePointer);
cis.SetTotalBytesLimit(INT_MAX, INT_MAX >> 2);
int oldLimit = cis.PushLimit(mapLevel->length); int oldLimit = cis.PushLimit(mapLevel->length);
readMapLevel(&cis, mapLevel, true); readMapLevel(&cis, &(*mapLevel), true);
cis.PopLimit(oldLimit); cis.PopLimit(oldLimit);
} }
lseek(file->fd, 0, SEEK_SET); lseek(file->fd, 0, SEEK_SET);