From c8a603d853c7b7973816201d4fb3c6fcde84de92 Mon Sep 17 00:00:00 2001 From: Leonid Beynenson Date: Thu, 14 Jul 2011 18:41:09 +0000 Subject: [PATCH] Fixed bug in the function of search of Android applicvation path. --- modules/androidcamera/src/camera_activity.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/modules/androidcamera/src/camera_activity.cpp b/modules/androidcamera/src/camera_activity.cpp index 34d8501b6e..a54f1aa017 100644 --- a/modules/androidcamera/src/camera_activity.cpp +++ b/modules/androidcamera/src/camera_activity.cpp @@ -264,6 +264,10 @@ 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"); @@ -271,11 +275,9 @@ std::string CameraWrapperConnector::getPathLibFolder() { 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; } @@ -305,7 +307,6 @@ std::string CameraWrapperConnector::getPathLibFolder() fclose(file); return pathBegin; - } } fclose(file); LOGE("Could not find library path."); -- GitLab