Browse Source

* Patch from Thierry Gayet to fix crash when no options are specified on command-line

Michaël Van Canneyt 1 year ago
parent
commit
04e715445f
2 changed files with 9 additions and 4 deletions
  1. 2 0
      packages/webidl/src/webidltopas.pp
  2. 7 4
      utils/pas2js/webidl2pas.pp

+ 2 - 0
packages/webidl/src/webidltopas.pp

@@ -274,6 +274,7 @@ Var
 
 begin
   P:=Nil;
+  S:=Nil;
   ms:=TMemoryStream.Create;
   try
     if InputStream<>nil then
@@ -292,6 +293,7 @@ begin
   end;
 end;
 
+
 function TBaseWebIDLToPas.GetName(ADef: TIDLDefinition): String;
 
 begin

+ 7 - 4
utils/pas2js/webidl2pas.pp

@@ -162,11 +162,9 @@ begin
     ]);
   if (ErrorMsg<>'') or HasOption('h','help') then
     begin
+    ErrorMsg:='Missing input filename';
     WriteHelp(ErrorMsg);
-    if ErrorMsg<>'' then
-      Halt(1)
-    else
-      Exit;
+    Exit();
     end;
 
   // first read outputformat and create FWebIDLToPas
@@ -210,6 +208,11 @@ begin
     FWebIDLToPas.GlobalVars.CommaText:=A;
 
   InputFileName:=GetOptionValue('i','input');
+  if (InputFileName='') then
+  begin
+    WriteHelp('Missing input filename');
+    Exit();
+  end;
 
   if HasOption('m','implementation') then
     FWebIDLToPas.IncludeImplementationCode.LoadFromFile(GetOptionValue('m','implementation'));