opkg: Fix a bug that ap may undefined.
authorticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Mon, 15 Dec 2008 05:25:37 +0000 (05:25 +0000)
committerticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Mon, 15 Dec 2008 05:25:37 +0000 (05:25 +0000)
  by Alexandros Kostopoulos <akostop@inaccessnetworks.com>

git-svn-id: http://opkg.googlecode.com/svn/trunk@138 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

libopkg/user.c

index af133bac8763f0add2fb0eb4bb3e1ae201863b98..04dfd9e157a5251f3c1e4e462a6dafdf1e5ad649 100644 (file)
@@ -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);