Fixed bug in the function of search of Android applicvation path.
This commit is contained in:
parent
b16fb5d518
commit
c8a603d853
@ -264,18 +264,20 @@ std::string CameraWrapperConnector::getPathLibFolder()
|
||||
sprintf(addrBuf, "%p-", dl_info.dli_fbase);
|
||||
int addrLength = strlen(addrBuf);
|
||||
|
||||
const char* libName=dl_info.dli_fname;
|
||||
while( ((*libName)=='/') || ((*libName)=='.') )
|
||||
libName++;
|
||||
|
||||
char lineBuf[2048];
|
||||
FILE* file = fopen("/proc/self/smaps", "rt");
|
||||
|
||||
if(file)
|
||||
{
|
||||
while (fgets(lineBuf, sizeof lineBuf, file) != NULL)
|
||||
{
|
||||
if(0 == strncmp(lineBuf, addrBuf, addrLength))
|
||||
{
|
||||
//verify that line ends with library name
|
||||
int lineLength = strlen(lineBuf);
|
||||
int libNameLength = strlen(dl_info.dli_fname);
|
||||
int libNameLength = strlen(libName);
|
||||
|
||||
//trim end
|
||||
for(int i = lineLength - 1; i >= 0 && isspace(lineBuf[i]); --i)
|
||||
@ -284,9 +286,9 @@ std::string CameraWrapperConnector::getPathLibFolder()
|
||||
--lineLength;
|
||||
}
|
||||
|
||||
if (0 != strncmp(lineBuf + lineLength - libNameLength, dl_info.dli_fname, libNameLength))
|
||||
if (0 != strncmp(lineBuf + lineLength - libNameLength, libName, libNameLength))
|
||||
{
|
||||
LOGE("Strange error: line \"%s\" does not ends with library name %s", lineBuf, dl_info.dli_fname);
|
||||
//the line does not contain the library name
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -306,7 +308,6 @@ std::string CameraWrapperConnector::getPathLibFolder()
|
||||
fclose(file);
|
||||
return pathBegin;
|
||||
}
|
||||
}
|
||||
fclose(file);
|
||||
LOGE("Could not find library path.");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user