@@ -1035,39 +1035,71 @@ bool command_get_status(command_t *cmd, const char* arg)
10351035{
10361036 size_t _len ;
10371037 char reply [4096 ];
1038- uint8_t flags = content_get_flags ();
1038+ uint8_t flags ;
1039+
1040+ if (!cmd )
1041+ return false;
1042+
1043+ if (!cmd -> replier )
1044+ return false;
1045+
1046+ flags = content_get_flags ();
10391047
10401048 if (flags & CONTENT_ST_FLAG_IS_INITED )
10411049 {
10421050 /* add some content info */
10431051 core_info_t * core_info = NULL ;
10441052 runloop_state_t * runloop_st = runloop_state_get_ptr ();
1053+ const char * basename_path = NULL ;
1054+
1055+ if (!runloop_st )
1056+ {
1057+ _len = strlcpy (reply , "GET_STATUS ERROR" , sizeof (reply ));
1058+ cmd -> replier (cmd , reply , _len );
1059+ return false;
1060+ }
10451061
10461062 core_info_get_current_core (& core_info );
10471063
1048- _len = strlcpy (reply , "GET_STATUS " , sizeof (reply ));
1064+ _len = strlcpy (reply , "GET_STATUS " , sizeof (reply ));
1065+
10491066 if (runloop_st -> flags & RUNLOOP_FLAG_PAUSED )
10501067 _len += strlcpy (reply + _len , "PAUSED" , sizeof (reply ) - _len );
10511068 else
10521069 _len += strlcpy (reply + _len , "PLAYING" , sizeof (reply ) - _len );
1053- _len += strlcpy (reply + _len , " " , sizeof (reply ) - _len );
1054- if (core_info )
1070+
1071+ _len += strlcpy (reply + _len , " " , sizeof (reply ) - _len );
1072+
1073+ if (core_info && core_info -> system_id )
10551074 _len += strlcpy (reply + _len , core_info -> system_id ,
10561075 sizeof (reply ) - _len );
1057- else
1076+ else if ( runloop_st -> system . info . library_name )
10581077 _len += strlcpy (reply + _len , runloop_st -> system .info .library_name ,
10591078 sizeof (reply ) - _len );
1060- _len += strlcpy (reply + _len , "," , sizeof (reply ) - _len );
1061- _len += strlcpy (reply + _len ,
1062- path_basename (path_get (RARCH_PATH_BASENAME )), sizeof (reply ) - _len );
1063- _len += snprintf (reply + _len , sizeof (reply ) - _len ,
1079+ else
1080+ _len += strlcpy (reply + _len , "UNKNOWN" , sizeof (reply ) - _len );
1081+
1082+ _len += strlcpy (reply + _len , "," , sizeof (reply ) - _len );
1083+
1084+ basename_path = path_get (RARCH_PATH_BASENAME );
1085+ if (basename_path )
1086+ {
1087+ const char * basename = path_basename (basename_path );
1088+ if (basename )
1089+ _len += strlcpy (reply + _len , basename , sizeof (reply ) - _len );
1090+ else
1091+ _len += strlcpy (reply + _len , "UNKNOWN" , sizeof (reply ) - _len );
1092+ }
1093+ else
1094+ _len += strlcpy (reply + _len , "UNKNOWN" , sizeof (reply ) - _len );
1095+
1096+ _len += snprintf (reply + _len , sizeof (reply ) - _len ,
10641097 ",crc32=%lx\n" , (unsigned long )content_get_crc ());
10651098 }
10661099 else
1067- _len = strlcpy (reply , "GET_STATUS CONTENTLESS" , sizeof (reply ));
1100+ _len = strlcpy (reply , "GET_STATUS CONTENTLESS" , sizeof (reply ));
10681101
10691102 cmd -> replier (cmd , reply , _len );
1070-
10711103 return true;
10721104}
10731105
0 commit comments