about summary refs log tree commit diff
path: root/generator
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2022-07-21 18:22:31 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2022-07-21 18:22:31 +0000
commitb49c23f7f948a2f453b4a8580e52692742e6163f (patch)
tree2272fc100293e3fd95474f889ef949f3334046f0 /generator
parentd2cd302a66f850f27c775ff68faa42d5a7058956 (diff)
downloadnetpbm-mirror-b49c23f7f948a2f453b4a8580e52692742e6163f.tar.gz
netpbm-mirror-b49c23f7f948a2f453b4a8580e52692742e6163f.tar.xz
netpbm-mirror-b49c23f7f948a2f453b4a8580e52692742e6163f.zip
check for null font name; clean up other command line validation
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4366 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'generator')
-rw-r--r--generator/pbmtextps.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/generator/pbmtextps.c b/generator/pbmtextps.c
index 0c3656e7..a3e9124a 100644
--- a/generator/pbmtextps.c
+++ b/generator/pbmtextps.c
@@ -52,6 +52,9 @@ validateFontName(const char * const name) {
 -----------------------------------------------------------------------------*/
     unsigned int idx;
 
+    if (name[0] == '\0')
+        pm_error("Font name is empty string");
+
     for (idx = 0; name[idx] != '\0'; ++idx) {
         char const c = name[idx];
 
@@ -244,6 +247,8 @@ parseCommandLine(int argc, const char ** argv,
 
     validateFontName(cmdlineP->font);
 
+    if (cmdlineP->res <= 0)
+        pm_error("-resolution must be positive");
     if (cmdlineP->fontsize <= 0)
         pm_error("-fontsize must be positive");
     if (cmdlineP->ascent < 0)
@@ -413,11 +418,8 @@ gsArgList(const char *       const outputFilename,
     const char ** retval;
     unsigned int argCt;  /* Number of arguments in 'retval' so far */
 
-    if (cmdline.res <= 0)
-         pm_error("Resolution (dpi) must be positive.");
-
-    if (cmdline.fontsize <= 0)
-         pm_error("Font size must be positive.");
+    assert(cmdline.res > 0);
+    assert(cmdline.fontsize > 0);
 
     MALLOCARRAY_NOFAIL(retval, maxArgCt+2);