Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the potential risk of shape and a Error of OgrLayer #161

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/COM classes/OgrLayer.cpp
Expand Up @@ -84,7 +84,12 @@ void COgrLayer::StopBackgroundLoading()
IShapefile* COgrLayer::LoadShapefile()
{
bool isTrimmed = false;
IShapefile* sf = Ogr2Shape::Layer2Shapefile(_layer, _activeShapeType, _loader.GetMaxCacheCount(), isTrimmed, &_loader, _globalCallback);
ShpfileType shpType;
get_ShapeType(&shpType);

shpType = shpType != SHP_NULLSHAPE ? shpType : _activeShapeType;

IShapefile* sf = Ogr2Shape::Layer2Shapefile(_layer, shpType, _loader.GetMaxCacheCount(), isTrimmed, &_loader, _globalCallback);
if (isTrimmed) {
ErrorMessage(tkOGR_LAYER_TRIMMED);
}
Expand Down
11 changes: 11 additions & 0 deletions src/COM classes/Shape.cpp
Expand Up @@ -2593,11 +2593,22 @@ STDMETHODIMP CShape::ImportFromWKT(BSTR Serialized, VARIANT_BOOL *retVal)
*retVal = VARIANT_FALSE;

USES_CONVERSION;
/*
CString ser = OLE2A(Serialized);

OGRGeometry* oGeom = NULL;
char* buffer = ser.GetBuffer();
OGRErr err = OGRGeometryFactory::createFromWkt(&buffer, NULL, &oGeom);
*/

char* pBuf = _com_util::ConvertBSTRToString(Serialized);

char *pszBuffBack = pBuf;

OGRGeometry* oGeom = NULL;
OGRErr err = OGRGeometryFactory::createFromWkt(&pBuf, NULL, &oGeom);
delete[] pszBuffBack;

if (err != OGRERR_NONE || !oGeom)
{
ErrorMessage(tkINVALID_SHAPE);
Expand Down
1 change: 1 addition & 0 deletions src/COM classes/Shape.h
Expand Up @@ -20,6 +20,7 @@

#pragma once
//
#include <comutil.h>
#include "ShapeInterfaces.h"
#include "OgrConverter.h"
#include "ShapeWrapper.h"
Expand Down