mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-04 17:10:47 +00:00
Fix crash trying to capture invalid app name
Before the code change this command renderdoccmd capture ~/dsdsds.app would trigger segmentation fault accessing a null pointer
This commit is contained in:
committed by
Baldur Karlsson
parent
59ca2811ef
commit
ee73091d54
@@ -23,6 +23,7 @@
|
||||
******************************************************************************/
|
||||
|
||||
#include "api/replay/rdcstr.h"
|
||||
#include "common/common.h"
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@@ -62,8 +63,20 @@ bool apple_IsKeyPressed(int appleKeyCode)
|
||||
rdcstr apple_GetExecutablePathFromAppBundle(const char *appBundlePath)
|
||||
{
|
||||
NSString *path = [NSString stringWithCString:appBundlePath encoding:NSUTF8StringEncoding];
|
||||
|
||||
NSBundle *nsBundle = [NSBundle bundleWithPath:path];
|
||||
if(!nsBundle)
|
||||
{
|
||||
RDCERR("Failed to open application '%s' as an NSBundle", appBundlePath);
|
||||
return rdcstr();
|
||||
}
|
||||
|
||||
NSString *executablePath = nsBundle.executablePath;
|
||||
if(!executablePath)
|
||||
{
|
||||
RDCERR("Failed to get executable path from application '%s'", appBundlePath);
|
||||
return rdcstr();
|
||||
}
|
||||
|
||||
rdcstr result([executablePath cStringUsingEncoding:NSUTF8StringEncoding]);
|
||||
return result;
|
||||
|
||||
@@ -540,6 +540,11 @@ static pid_t RunProcess(rdcstr appName, rdcstr workDir, const rdcstr &cmdLine, c
|
||||
if(appName.size() > 5 && appName.endsWith(".app"))
|
||||
{
|
||||
rdcstr realAppName = apple_GetExecutablePathFromAppBundle(appName.c_str());
|
||||
if(realAppName.empty())
|
||||
{
|
||||
RDCERR("Invalid application path '%s'", appName.c_str());
|
||||
return (pid_t)0;
|
||||
}
|
||||
|
||||
if(FileIO::exists(realAppName))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user