Skip to content

Commit

Permalink
ubuntu Dockerfile for testing with valgrind
Browse files Browse the repository at this point in the history
  • Loading branch information
codekitchen committed Nov 29, 2019
1 parent c07c55c commit 8623240
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM ubuntu:latest

RUN set -e; \
apt-get update; \
apt-get install -y \
autoconf \
build-essential \
git \
libreadline-dev \
libncurses5-dev \
valgrind \
; \
rm -rf /var/lib/apt/lists/*

COPY . /pipeline
WORKDIR /pipeline

RUN set -e; \
autoreconf -fi; \
./configure; \
make install

ENV LANG C.UTF-8
3 changes: 3 additions & 0 deletions dev/valgrind
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

valgrind --log-file=valgrind.log --track-origins=yes ./pipeline
7 changes: 7 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
#include <term.h>
#include <unistd.h>
Expand Down Expand Up @@ -59,9 +60,15 @@ void termput1(char *cmd, int arg1) {
}

void str_append(wchar_t **line, ssize_t *len, size_t *cap, wchar_t c) {
// Note that cap (and len) are # of wchar_t not # of bytes.
if (*len == *cap) {
*cap = *cap < 255 ? 255 : *cap * 2;
*line = abort_null(realloc(*line, *cap * sizeof(wchar_t)));
// This memset isn't strictly necessary because we zero-terminate the
// string later. But valgrind sees uninitialized reads in printf because
// it uses vector operators that read past the zero, so rather than add
// suppressions I'm just zeroing all the buffer.
memset((*line) + (*len), 0, ((*cap) - (*len)) * sizeof(wchar_t));
}
(*line)[(*len)++] = c;
}
Expand Down

0 comments on commit 8623240

Please sign in to comment.