0028679: Foundation Classes - OSD_Process::UserName rises EXC_BAD_ACCESS on iphone...
authoribs <ibs@opencascade.com>
Mon, 24 Apr 2017 16:23:55 +0000 (19:23 +0300)
committerbugmaster <bugmaster@opencascade.com>
Fri, 28 Apr 2017 09:44:53 +0000 (12:44 +0300)
check for a null pointer is added

src/OSD/OSD_Process.cxx

index c237346..84a1d57 100644 (file)
@@ -84,12 +84,10 @@ Standard_Integer OSD_Process::ProcessId(){
  return (getpid());
 }
 
-TCollection_AsciiString OSD_Process::UserName(){
- struct passwd *infos;
- infos = getpwuid(getuid()); 
- TCollection_AsciiString result=infos->pw_name;
-
- return(result);
+TCollection_AsciiString OSD_Process::UserName()
+{
+  struct passwd *anInfos = getpwuid (getuid());
+  return TCollection_AsciiString (anInfos ? anInfos->pw_name : "");
 }
 
 Standard_Boolean OSD_Process::IsSuperUser (){