Changeset 897 for cpp/common


Ignore:
Timestamp:
11/30/19 01:46:51 (4 years ago)
Author:
Maciej Komosinski
Message:

A workaround for Android bug in vsnprintf() and vsprintf() needed in more classes (introduced earlier in r892), ​https://github.com/android-ndk/ndk/issues/879

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/common/util-string.cpp

    r892 r897  
    5353                        if (n < 0) //vsprintf was also buggy. If we were strict, we should abort the app now.
    5454                        {
    55                                 strcpy(buf, "[STR_ERR] "); //just to indicate the returned string is invalid
    56                                 strcat(buf, format); //return just the original formatting string
    57                                 __android_log_print(ANDROID_LOG_ERROR, LOG_APP_NAME, "vsprintf() also failed, returning incorrect string '%s'", buf);
     55                                strcpy(buf, "[STR_ERR] "); //a special prefix just to indicate the returned string is incorrect
     56                                strcat(buf, format); //append and return the original formatting string
     57                                __android_log_print(ANDROID_LOG_ERROR, LOG_APP_NAME, "vsprintf() also failed, using the incorrect resulting string: '%s'", buf);
    5858                        }
    59                         n = 0; //pretend vsnprintf() or vsprintf() was OK to exit the endless loop
     59                        n = strlen(buf); //pretend vsnprintf() or vsprintf() was OK to exit the endless loop
    6060                }
    6161#endif
Note: See TracChangeset for help on using the changeset viewer.