]> git.vpit.fr Git - perl/modules/Mac-NSGetExecutablePath.git/blobdiff - NSGetExecutablePath.xs
Guard against the case where the size is zero
[perl/modules/Mac-NSGetExecutablePath.git] / NSGetExecutablePath.xs
index c0a3a93bccce1e339aa4617a75fd5f2be1577e67..b9ef190a3a26ab41e5dfb5d17e335e2922561ae3 100644 (file)
@@ -29,16 +29,13 @@ PPCODE:
  _NSGetExecutablePath(buf, &size);
  if (size >= MAXPATHLEN * MAXPATHLEN)
   croak(nsgep_too_long);
-#ifdef newSV_type
- dst = newSV_type(SVt_PV);
-#else
- dst = sv_newmortal();
- (void) SvUPGRADE(dst, SVt_PV);
-#endif
+ dst    = sv_newmortal();
+ sv_upgrade(dst, SVt_PV);
  buffer = SvGROW(dst, size);
  if (_NSGetExecutablePath(buffer, &size))
   croak(nsgep_too_long);
- SvCUR_set(dst, size - 1);
+ if (size)
+  SvCUR_set(dst, size - 1);
  SvPOK_on(dst);
  XPUSHs(dst);
  XSRETURN(1);