opkg: Fix a bug that ap may undefined.
[oweals/opkg-lede.git] / libopkg / user.c
index 2467de9958eef51a08381356223011efb5b61db5..04dfd9e157a5251f3c1e4e462a6dafdf1e5ad649 100644 (file)
@@ -1,4 +1,4 @@
-/* user.c - the itsy package management system
+/* user.c - the opkg package management system
 
    Jamey Hicks
 
@@ -33,14 +33,16 @@ char *get_user_response(const char *format, ...)
      int len = question_len;
      va_list ap;
      char *response;
-     va_start(ap, format);
 
      do {
          if (question == NULL || len > question_len) {
               question = realloc(question, len + 1);
               question_len = len;
          }
+
+          va_start(ap, format);
          len = vsnprintf(question,question_len,format,ap);
+          va_end(ap);
      } while (len > question_len);
      response = strdup(opkg_cb_response(question));
      str_chomp(response);