shithub: mc

Download patch

ref: a713d2171d4f26689fc063ebf01569514d1f9932
parent: df3f645e8691393d3436f98676924ba8a17a5a4f
author: Ori Bernstein <[email protected]>
date: Wed Oct 8 21:58:58 EDT 2014

Exit program on bad arguments.

--- a/parse/util.c
+++ b/parse/util.c
@@ -13,6 +13,7 @@
 
 #include "parse.h"
 
+/* malloc wrappers */
 void *zalloc(size_t sz)
 {
     void *mem;
@@ -52,6 +53,7 @@
     return mem;
 }
 
+/* errors */
 void die(char *msg, ...)
 {
     va_list ap;
@@ -119,6 +121,7 @@
     return memcpy(ret, mem, len);
 }
 
+/* lists */
 void lappend(void *l, size_t *len, void *n)
 {
     void ***pl;
@@ -179,6 +182,7 @@
     *len = 0;
 }
 
+/* endian packing */
 void be64(vlong v, byte buf[8])
 {
     buf[0] = (v >> 56) & 0xff;
@@ -491,6 +495,7 @@
     ctx->curarg++;
     if (!optinfo(ctx, c, &take, &mand)) {
         printf("Unexpected argument %c\n", *ctx->curarg);
+        exit(1);
     }
 
     ctx->optarg = NULL;